473,403 Members | 2,323 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Extract file name from full path?

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
3 3607
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Paul | last post by:
Hi, Using the code below I can extract the filename from a path but I would like to know how to get just the path too. So if the full path is "C:\A Long Time Ago\In A Galaxy\Far Far...
12
by: Xah Lee | last post by:
would anyone like to translate the following perl script to Python or Scheme (scsh)? the file takes a inpath, and report all html files in it above certain size. (counting inline images) also...
3
by: Xah Lee | last post by:
Split File Fullpath Into Parts Xah Lee, 20051016 Often, we are given a file fullpath and we need to split it into the directory name and file name. The file name is often split into a core...
3
by: Wayne Aprato | last post by:
I am using code kindly provided by the Access Web to capture a file path and insert it into a form. The relevant part of the code follows: Function GetOpenFile(Optional varDirectory As Variant,...
5
by: Kristoffer Persson | last post by:
It's probably very simple... I would like to know if there is a function similar to ExtractFileName() (I've used it in Delphi), which returns only the file name from the full path, e.g....
5
by: steve | last post by:
How can someone extract the file name and file path from a complete path? ex: c:\mydir\subdir\temp\myfile.txt will give: path = c:\mydir\subdir\temp filename = myfile.txt TIA
17
by: spentun | last post by:
How can I moitor file which is executed by user or program in window. I need to write a code to monitor file. When user clicks the file(.exe) or is called by program, the name of file will be...
2
by: Sridhar | last post by:
Hi, I have a web form where it has a <input type=file id=file1> control. I have an Upload button to upload the file. WHen I click on browse and select one file, it is showing the full file path...
65
by: Hongyu | last post by:
Dear all: I am trying to write to a file with full directory name and file name specified (./outdir/mytestout.txt where . is the current directory) in C programming language and under Unix, but...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.