Peter Kiers
asked on
Save file to location with the SaveFileDialog but the file allready exists!
Hi,
What can I do to save a file to a certain location with the SaveFileDialog but the same file allready exists! I get an message to override it. And I click Yes. But then I get an error:
System.IO.IOExeption: the file c:\Users\Peter\Desktop\DBR oot.bak already exists.
Greetings, Peter Kiers
What can I do to save a file to a certain location with the SaveFileDialog but the same file allready exists! I get an message to override it. And I click Yes. But then I get an error:
System.IO.IOExeption: the file c:\Users\Peter\Desktop\DBR
private void bbBackup_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
string pathDB = Application.StartupPath + "\\DBRoot.mdb";
glucsTA.Update(glucsDS);
glucsDS.AcceptChanges();
suppTA.Update(suppDS);
suppDS.AcceptChanges();
favorTA.Update(favorDS);
favorDS.AcceptChanges();
calenTA.Update(calenDS);
calenDS.AcceptChanges();
SaveFileDialog saveFileDlg = new SaveFileDialog();
saveFileDlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
saveFileDlg.Filter = "Backup File (*.bak)|*.bak";
saveFileDlg.FileName = "DBRoot.bak";
try
{
if (saveFileDlg.ShowDialog() == DialogResult.OK)
{
System.IO.File.Copy(pathDB, saveFileDlg.FileName);
}
}
catch (Exception ex)
{
XtraMessageBox.Show(ex.ToString());
}
}
Greetings, Peter Kiers
use date/time in the default file name then it does not exist.
ASKER
I don't understand could you help me?
Greetings, Peter
Greetings, Peter
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ah, yes indeed James your right. Thank for the solution.
Greetings, Peter Kiers
Greetings, Peter Kiers