empty path name is not legal Error
im working on a notepad application when i click on open or save command n after click on cancel in opendialoge box i got error.
Code:
private void openToolStripMenuItem_Click(object sender, EventArgs e)
{
OpenFileDialog dlg = new OpenFileDialog();
dlg.Title = "Open";
dlg.Filter = "Text Documents(*.*)|*.*|All Files(*.*)|*.*";
dlg.ShowDialog();
richTextBox1.LoadFile(dlg.FileName);
}
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
{
SaveFileDialog dlg = new SaveFileDialog();
dlg.Title = "Open";
dlg.Filter = "Text Documents(*.*)|*.*|All Files(*.*)|*.*";
dlg.ShowDialog();
richTextBox1.SaveFile(dlg.FileName);
}
Re: empty path name is not legal Error
You should check your ShowDialog(); calls return values in order to find out which button was actually pressed.
Something like that
Code:
......................................
// Show dlg as a modal dialog and determine if DialogResult = OK.
if (dlg.ShowDialog() == DialogResult.OK)
{
...............................
}
Re: empty path name is not legal Error