Get filename without the path - Beginner in VB

A

Andy

Hi

I have a filedialog that returns the entire path and the filename of a given
file.
How can I remove the filepath from the filename property and only have the
basic filename.
Say I have a file test.txt located in c:\users\username, then the
filedialog.filename property returns "c:\users\username\test.txt".
What I need is a way to remove "C:\users\username" and only have the
test.txt entry.

It is probably an easy task, but I can't see it.

/A.
 
H

Harry

Andy said:
Hi

I have a filedialog that returns the entire path and the filename of a
given file.
How can I remove the filepath from the filename property and only have the
basic filename.
Say I have a file test.txt located in c:\users\username, then the
filedialog.filename property returns "c:\users\username\test.txt".
What I need is a way to remove "C:\users\username" and only have the
test.txt entry.

It is probably an easy task, but I can't see it.

/A.
System.IO.Path.GetFileName("c:\users\username\test.txt")
 

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