Tag Archives: FileSystem

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)

        MsgBox(filePathNoEx)

 

Check if a Specified File or Directory Exists in VB 2008/2010 and Newer

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

Shows how to use Visual Basic.NET 2005/2008/2010 and Higher to check if a file and if a folder or directory exists or not.

MsgBox(My.Computer.FileSystem.FileExists("c:\theFile.txt"))
MsgBox(My.Computer.FileSystem.DirectoryExists("c:\"))