-
June 13th, 2012, 03:24 AM
#1
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);
}
-
June 13th, 2012, 03:32 AM
#2
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)
{
...............................
}
-
June 13th, 2012, 03:43 AM
#3
Re: empty path name is not legal Error
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|