I have a bit of a problem with my text editor program with the open dialog,it works perfectly when you actually select a file but if you cancel out it throws an exception as shown:
openFileDialog1.ShowDialog();
if (saveFileDialog1.InitialDirectory.Equals(saveFileDialog1.RestoreDirectory))
{
MessageBox.Show("Didnt make a selection");
}
else
{
txtUI.Text = File.ReadAllText(openFileDialog1.FileName);
}
saveFileDialog1.FileName = "Please click on the file you want to open";
I have tried this if-else statement but it doesn't seem to work.