Getting rid of the file location when writing to a text file

Another solution

You can also manipulate the string. Its not as short as GetFileName but you might find these functions useful in other situations as well.

Code:
        Dim TempString As String, FileName As String
        Dim FullPath As String = "C:\My Folder\My File.txt"

        TempString = StrReverse(FullPath) Returns "txt.eliF yM\redloF yM\:C"
        TempString = Split(TempString, "\")(0) Returns "txt.eliF yM"
        FileName = StrReverse(TempString) Returns "My File.txt"
 
Back
Top