[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


EASY STRING Q???????????

Posted on 2005-04-15
Medium Priority
Last Modified: 2010-04-24
I have a string array that holds file paths but is nothing more then a file path with a file at the end of it.


How can I get the name of the text file so everything to the right of the last "\"???  When the file path to the file could be longer or shorter??  
Question by:macros14
  • 2
LVL 12

Accepted Solution

S-Twilley earned 1000 total points
ID: 13791170
Dim fi as New IO.FileInfo(strPath)
Msgbox fi.name


That's one of many ways
LVL 12

Expert Comment

ID: 13791186

'as above, strPath contains the full filename

dim i as integer = strPath.LastIndexOf("\")
Dim filename as string = ""

If i >= 0 Then
    filename = strPath.Substring(i+1)
    filename = strPath
End if

LVL 86

Expert Comment

by:Mike Tomlinson
ID: 13791240
Another possibility:

Dim fullPathFileName As String = "C:\mydir\myfile.ext"
Dim fileName As String = System.IO.Path.GetFileName(fullPathFileName)

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Integration Management Part 2
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

868 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question