我应该在哪里保存数据库文件?
到目前为止,在开发过程中,我的应用程序一直将其数据库存储在应用程序基目录中。 当它部署时,它将位于程序文件中,所以我不能将它们保留在那里!
明显的地方是:
Environment.SpecialFolder.LocalApplicationData
Environment.SpecialFolder.ApplicationData
一个问题是数据下载可以从预定任务运行,因此我必须确保任务在同一用户下运行。
主要问题是几年后,这些数据库文件可能总计 5 到 10GB,所以我觉得我应该在安装后给用户一个选择数据库位置的选项。 我必须确保它是可写的而不是网络位置。
其他人提出了什么解决方案?
So far in development, my application has been storing its databases in the app base directory. When it is deployed this will be in program files so I cant keep them there!
The obvoius places are:
Environment.SpecialFolder.LocalApplicationData
Environment.SpecialFolder.ApplicationData
One problem is that data downloads can be run from sceduled tasks so I would have to ensure tasks were run under the same user.
The major issue is that after a couple of years, these database files could total 5 to 10GB, so I feel like I should give the user an option after install to choose the database location. I'd have to ensure that it was writable and not a network location.
What solutions have others come up with?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
关于检查目录的写访问权限:到目前为止,我没有找到比在目录中创建文件并立即删除它更好的方法。 如果您在这些步骤中遇到错误,则说明您没有足够的权限。 (请记住首先检查驱动器上是否有足够的可用空间)。
我曾经尝试通过访问控制列表以编程方式解决这个问题,但后来我遇到了一个目录,我在其中写入了权限,但没有列出 ACL 的权限...
您可以通过以下方式检查给定驱动器是否是网络共享使用 < 的
DriveType
属性code>System.IO.DriveInfo 对象。 至于处理 UNC 路径,我还没有找到比(myPath.Substring(0,2) == @"\\")
更好的方法About checking the write access to a directory: So far I have found no better way than to create a file in the directory and immediately delete it. If you encounter an error during these steps, you have insufficient privilegs. (Just remember to first check if there is enough free space on the drive).
I once tried to solve this programmatically by going through the access control lists, but then i encountered a dir where I had write priviliges, but not the right to list the ACLs...
You can check if a given drive is a network share by using the
DriveType
property of theSystem.IO.DriveInfo
object. As for handling UNC pathes, I have yet to find a better way than(myPath.Substring(0,2) == @"\\")