Stripping just the filename

G

Guest

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?
 
G

Guest

Greg,

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

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

Kerry Moorman
 
C

Cyril Gupta

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

Cyril Gupta
 

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

Top