Extract file name from full path?

  • Thread starter Thread starter Bill
  • Start date Start date
B

Bill

Is there a method that will take a full path and filename as a
parameter and return just the filename? I am currently using the
following code but it is extremely slow for files on a DVD.

for (int I = 0; I < openVobDialog.FileNames.Length; I++)
{
FileInfo vobInfo = new FileInfo(openVobDialog.FileNames);
vobListBox.Items.Add(vobInfo.Name);
}
 
Hi there... you can use the System.IO.Path.GetFileName() method. For
example:

String myfullpath = @"c:\Folder1\SubFolder\MyFile.txt";
MessageBox.Show(System.IO.Path.GetFileName(myfullpath)); // Shows MyFile.txt

Regards,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top