file dialog help

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi,

i've used a filedialog ox on my winform...
I want the system to pop up a message when the user doens't selects any
file...
how can i do this validation...any help
 
Hello AVL,

if(openFileDialog1.ShowDialog() == DialogResult.OK)
{
if (string.IsNullOrEmpty(openFileDialog1.FileName) )
{
// No file selected
MessageBox.Show("You've selected nothing");
}
}


---
WBR, Michael Nemtsev [.NET/C# MVP].
My blog: http://spaces.live.com/laflour
Team blog: http://devkids.blogspot.com/

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo

A> hi,
A>
A> i've used a filedialog ox on my winform...
A> I want the system to pop up a message when the user doens't selects
A> any
A> file...
A> how can i do this validation...any help
 
If you mean, you want to show the message while the dialog is still active
and prevent the user from selecting a invalid/null file, then I don't think
there is any way to do this with the standard file dialog class. You can use
3rd party controls such as the ones from http://www.ssware.com
These are commercial products though.
 
Hello.

There are special Open/Save dialogs in our Dialog Workshop .NET component
package.

Using the following code:

private void caOpenFileDialog_AcceptDialog(object sender, CancelEventArgs e)
{
if (dlg.SelectedFile.Length == 0)
{
MessageBox.Show("No files selected");
e.Cancel = true;
}
}

you can display message then user presses OK button without selecting files.

Also many other additional features exist in these dialog components.

Please visit http://www.componentage.com for additional information.

Regards,
Alexander
 
Back
Top