views:

265

answers:

1

My application needs to backup and restore .sdf files. There is a single dataSet the 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?

A: 

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;

(...)

Ruben Trancoso
the problem was not related to datasets or connections. Datasets just open the connection when needed and close it before retrieve the date, so the file is free to be copyied and replaced as well. The problem was just with the CurrentPath being changed by the openDialog
Ruben Trancoso