I’m making an application and I want to give a button to create Backup of database on the users desired location; like we save any file on any destination on computer and one button to restore the backup of whole database. How to accomplish this task?
I’m making backup through this code:
SqlCommand cmd = new SqlCommand(@"backup database StockDB to disk ='d:\StockDBBackUp1.bak' with init,stats=10", ConnectionClass.OpenConnection());
cmd.ExecuteNonQuery();
Now if I give a folder name d:\Backup\StockDBBackUp1.bak then it should check that is the folder is there already. If not, then it should to create the folder and create the backup.
You can use
System.IOfunctions to accomplish creating the directory: