Situation : Need to get a list of files in a directory, but I am currently getting the whole path of the file (Example: "C:\A Folder\Another Folder\file.txt"). What I want is just the filename and extension. So from above example, all I actually want is "file.txt".
Language: VB.NET 2005
Current Code:
-
Imports System.Collections.ObjectModel
-
...
-
Dim files As ReadOnlyCollection(Of String)
-
files = My.Computer.FileSystem.GetFiles(strCurDir)
-
Obviously, the GetFiles function returns a ReadOnlyCollection(Of String), so I cannot simply change it to below...
-
Imports System.Collections.ObjectModel
-
...
-
Dim files As ReadOnlyCollection(Of File)
-
files = My.Computer.FileSystem.GetFiles(strCurDir)
-
With just a string of something like "C:\Folder\Folder\Folder\somefile.txt", what would be the easiest method of getting everything after the last "\"?