Get file metadata

|

Create a project and add text box with a name of txtFileDetails and make it multi-line to run the code below.

Imports System
Imports System.IO

Public Class Form1

	Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
		Dim FileName As String
		FileName = "C:temp<EXE or DLL Filename>"
		txtFileDetails.Text += FileName & Environment.NewLine
		txtFileDetails.Text += (GetFileVersionInfo(FileName)) & Environment.NewLine
		txtFileDetails.Text += GetFileSize(FileName).ToString() & " Bytes"


	End Sub

	Function GetFileVersionInfo(ByVal filename As String) As String
		Return Version.Parse(FileVersionInfo.GetVersionInfo(filename).FileVersion).ToString()
	End Function

	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

End Class
Originally Posted on June 27, 2014
Last Updated on October 26, 2015
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.