Tag Archives: ext

Extract/Return the file Path and Filename without the Extension using VB.NET

Click Star to Rate Post
1 Star2 Stars3 Stars4 Stars5 Stars (4 votes, average: 4.50 out of 5)

This will take a file path, extract and return the filesystem path along with the filename but WITHOUT the extension.

        Dim filePath As String = "c:\MyDirectory\MYFile.txt"

        Dim extensionPosition As Integer = filePath.LastIndexOf(".")

        Dim filePathNoEx As String = filePath.Substring(0, extensionPosition)