How to Get a File Extension Using VB.NET
In this article I describe how to get a file extension in VB.NET.
Get a File Extension
The Extension property returns the extension of a file. The following code snippet returns the extension of a file.
Imports System.IO
Module Module1
Sub Main()
Dim fileName As String = "C:\Temp\MaheshTXFI.txt"
Dim fi As New IO.FileInfo(fileName)
Dim extn As String = fi.Extension
Console.WriteLine("File Extension: {0}", extn)
Console.ReadLine()
End Sub
End Module
Output:
