Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have the a file with the full path as shown below:

c:/the directory/pic.jpg

 

any function for me to use as to pick up only the file name?

the result I want from the above mentioned path is "pic.jpg"

George C.K. Low

Posted

dim strPath as string = "c:\directory\pic.jpg"

dim strFile as string

dim intPos as integer

 

intPos = strPath.lastindexof("\")

 

strFile = strPath.Substring(intPos + 1)

Live as if you were to die tomorrow. Learn as if you were to live forever.
Gandhi
  • *Experts*
Posted

The GetFileName method of the IO.Path class will do what you want. It is way more elegant then trying to extract it yourself.

Dim filename As String = System.IO.Path.GetFileName("path")
  

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...