[英]How can you move the Ado.net entity database?
At the moment my application has a database in the installation directory, but I would like to move it to the users local app data folder. 目前,我的应用程序在安装目录中有一个数据库,但是我想将其移动到用户本地应用程序数据文件夹中。 How can I do this?
我怎样才能做到这一点? CAN you do this?
你能做这个吗?
Well, you could do this: 好吧,你可以这样做:
File.Move(pathToDatabase,
Path.Combine(Environment.GetFolderPath(SpecialFolder.LocalApplicationData),
"databaseName.mdf"));
but you need to remember to change the connection string for the application as well (wherever you're storing that). 但您需要记住也要更改应用程序的连接字符串(无论您将其存储在何处)。
it would be better you mentioned which database technology you use but odds are high you can simply use File.Move. 最好提到使用哪种数据库技术,但是您可以简单地使用File.Move的可能性就很高。 of course dont forget to arrange connection string for new location.
当然不要忘记为新位置安排连接字符串。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.