georgepatotk Posted March 26, 2004 Posted March 26, 2004 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" Quote George C.K. Low
georgepatotk Posted March 26, 2004 Author Posted March 26, 2004 I found the solution Dim theName as string theName = "c:/the directory/pic.jpg" theName = theName.Substring(theName.LastIndexOf("\") + 1) Quote George C.K. Low
techmanbd Posted March 26, 2004 Posted March 26, 2004 dim strPath as string = "c:\directory\pic.jpg" dim strFile as string dim intPos as integer intPos = strPath.lastindexof("\") strFile = strPath.Substring(intPos + 1) Quote Live as if you were to die tomorrow. Learn as if you were to live forever. Gandhi
techmanbd Posted March 26, 2004 Posted March 26, 2004 You must have found the solution as I was writing Quote Live as if you were to die tomorrow. Learn as if you were to live forever. Gandhi
*Experts* mutant Posted March 26, 2004 *Experts* Posted March 26, 2004 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") Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.