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

Stripping just the filename

P: n/a
I have a string that contains both the filename and the directory. Something
like "c:\temp\test.txt". I need a process that will take this string and
return only the file portion "text.txt". How might I do this. Kept in mind
sometimes the string may contain "C:/temp/test.txt". Any ideas?
May 24 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Greg,

You can use the System.IO.Path class. For example:

MsgBox(System.IO.Path.GetFileName("C:/temp/test.txt"))

Kerry Moorman
"Greg Larsen" wrote:
I have a string that contains both the filename and the directory. Something
like "c:\temp\test.txt". I need a process that will take this string and
return only the file portion "text.txt". How might I do this. Kept in mind
sometimes the string may contain "C:/temp/test.txt". Any ideas?

May 24 '06 #2

P: n/a
This is definitely superior than parsing the string to extract the filename,
which I have been doing to do things like this.

Cyril Gupta
May 25 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.