VB.NET Finding a File Size

There may be some situations where you would like to retrieve the size of a given file. Below is a quick piece of code that will do exactly that. It will return the size of the file in bytes.

Imports System.IO

Private Function GetFileSize(ByVal MyFilePath As String) As Long
    Dim MyFile As New FileInfo(MyFilePath)
    Dim FileSize As Long = MyFile.Length
    Return FileSize
End Function

To display the file size in a human readable format see this post