How To Get File Name Using VB.NET

This article explains how to create FileInfo.The FileInfo class provides properties to get file name, extension, directory, size and file attributes.
  • 7268

Get File Name

The FileName property returns just the file name part of the full path of a file. The following code snippet returns the file name.

Imports System.IO

Module Module1

    Sub Main()

        Dim fileName As String = "C:\Temp\MaheshTXFI.txt"

        Dim fi As New IO.FileInfo(fileName)


        Dim justFileName As String = fi.Name

        Console.WriteLine("File Name: {0}", justFileName)


    End Sub

End Module


get file name.jpg


More Articles

© 2020 DotNetHeaven. All rights reserved.