OpenFileDialog

  • Thread starter Thread starter Jeff
  • Start date Start date
J

Jeff

Hi,
Is there a way when using the OpenFileDialog() to just get the
filename, myFile.dat, rather then the complete path. I use the
FileName returned from the OpenFilaDialog() and that does return the
path.

Thanks
Jeff
 
Hi Jeff,

Is there a way when using the OpenFileDialog() to just get the
filename, myFile.dat, rather then the complete path. I use the
FileName returned from the OpenFilaDialog() and that does return the
path.

Use System.IO.Path.GetFileName() to retrieve the filename:

if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
Debug.WriteLine(
System.IO.Path.GetFileName(
openFileDialog1.FileName));
}

Cheers

Arne Janning
 
Hi,
That still wound up returning the complete path. ex.
C:\adirectory\anotherone\file.dat

I am trying just to return the name ofthe file.

Jeff
 
Back
Top