简体   繁体   中英

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. of course dont forget to arrange connection string for new location.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM