开发者

Backup and Restore a SQLCE .sdf database

开发者 https://www.devze.com 2022-12-10 16:20 出处:网络
My application needs to backup and restore .sdf files. There is a single dataSet t开发者_如何学编程he the whole application and some bindngSource and table adapters on forms using this same dataset.

My application needs to backup and restore .sdf files. There is a single dataSet t开发者_如何学编程he the whole application and some bindngSource and table adapters on forms using this same dataset.

Just for a sake of test I tryied to copy the .sdf in runtime for a backup folder and back to restore it and I got my application not finding the file like it was not there anymore.

How should I manage connections to open and close the database since the dataSet do it automaticaly at begin and end of my application?


Got the answer

http://social.msdn.microsoft.com/forums/en-US/sqlce/thread/79d2f8a2-1366-4d14-8c61-220f47183368/

(...)

assign the OpenFileDialog.RestoreDirectory flag to true and then after it closes the original directory will be restored prior to the open dialog....that way you don't need the Directory.SetCurrentDirectory.

fileChooser = new OpenFileDialog();
fileChooser.RestoreDirectory = true;

(...)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号