By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,087 Members | 1,508 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,087 IT Pros & Developers. It's quick & easy.

Extract file name from full path?

P: n/a
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[i]);
vobListBox.Items.Add(vobInfo.Name);
}

--
..Bill.
Nov 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
See the static "GetFileName" method of the Path class...
http://msdn.microsoft.com/library/de...enametopic.asp

--
Tim Wilson
..Net Compact Framework MVP

"Bill" <no@no.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
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[i]);
vobListBox.Items.Add(vobInfo.Name);
}

--
.Bill.

Nov 17 '05 #2

P: n/a
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(myfullp ath)); // Shows MyFile.txt

Regards,
--
Angel J. Hernández M.
MCP - MCAD - MCSD - MCDBA
http://groups.msn.com/desarrolladoresmiranda
http://www.consein.com
"Bill" <no@no.com> escribió en el mensaje
news:%2****************@TK2MSFTNGP14.phx.gbl...
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[i]);
vobListBox.Items.Add(vobInfo.Name);
}

--
.Bill.

Nov 17 '05 #3

P: n/a
Thanks. That is what I needed.

--
..Bill.

Tim Wilson wrote:
See the static "GetFileName" method of the Path class...
http://msdn.microsoft.com/library/de...ry/en-us/cpref
/html/frlrfsystemiopathclassgetfilenametopic.asp

Nov 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.