The reason is :
I have the following code :
OpenFileDialog filedlg = new OpenFileDialog( );
filedlg.Initial Directory = directory.Text;
filedlg.Filter = "lvl files (*.lvl)|*.lvl" ;
filedlg.FileNam e = "*.lvl";
filedlg.Validat eNames = false;
if (filedlg.ShowDi alog() == DialogResult.Ca ncel)
return;
string dirname = Path.GetDirecto ryName(filedlg. FileName);
I set the property ValidateNames to false. I didn't select any file when
the dialog box pop-ups. When I click the "Open" button, the dialog box was
closed. The problem is filedlg.FileNam e doesn't not contain anything. I
expect it to have something like this c:\Test\*.lvl (with Win32
OpenFileDialog, it will). The protected member of OpenFileDialog namely
fileNames and FileNameInterna l do have the value but as it is a protected
member, the value is inaccessible. ) With OpenFileName Win32 API, I am able
to get the value.
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in
message news:O3******** ******@TK2MSFTN GP10.phx.gbl...
Tank,
I am curious, is there a reason you are not using the OpenFileDialog
or SaveFileDialog classes?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"Tank" <an*******@disc ussions.microso ft.com> wrote in message
news:eR******** ******@TK2MSFTN GP09.phx.gbl... How do I call OpenFileName Win32 API from C# ? Can someone show me a
sample code ?