How to Get a File Extension Using VB.NET

In this article I describe how to get a file extension in VB.NET.
  • 5470

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)


    End Sub

End Module


getfile extension.jpg


More Articles

© 2020 DotNetHeaven. All rights reserved.