L'exception COMException n'a pas été gérée
Bonjour,
Lorsque j'exécute ce code, j'ai une exception de type COMException (Impossible d'accéder à 'myfilename.txt').
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| private void SaveButton_Click(object sender, EventArgs e)
{
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
saveFileDialog1.InitialDirectory = @"C:\";
saveFileDialog1.Title = "Save text Files";
saveFileDialog1.CheckFileExists = false;
saveFileDialog1.CheckPathExists = false;
saveFileDialog1.FileName = "myfilename";
saveFileDialog1.DefaultExt = "txt";
saveFileDialog1.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*";
saveFileDialog1.FilterIndex = 2;
saveFileDialog1.RestoreDirectory = true;
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
string filename = saveFileDialog1.FileName;
workSheet.SaveAs(filename);
}
} |
Merci,