I want to save my backup file in specific folder. currently I'm using a saveFileDialog
box to give path
and file name on a button click
. But I want to create this backup by giving name as (DateTime.Today.Date.ToShortDateString())
and save this in "D:\\Database"
directly on button
click. and don't want to use saveFileDialog
box. I'm using this code:
SqlCommand cmd = new SqlCommand("USE MASTER BACKUP DATABASE plproject TO DISK = '" + saveFileDialog1.FileName + "'", connectionsql);
I guess you are looking for this
public static void WriteAllText(
string path,
string contents
)
File.WriteAllText("D:\\DataBase\\"+DateTime.Today.Date.ToShortDateString(),YOURDATASTRING);
Note: It will overwrite any file with same name.
There are many other useful methods available in FILE class. You can check which suits you best.
EDIT 1
Try this
string fileName="D:\\Backup\\"+DateTime.Today.Date.ToShortDateString();
SqlCommand cmd = new SqlCommand("USE MASTER BACKUP DATABASE plproject TO DISK = '" + fileName + "'", connectionsql);
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.