Determine a File's Size in Visual Basic:
To determine a file's size:
Use the GetFileInfo method to return a FileInfo object for the file, which can be queried for information. This example gets a FileInfo object for Testfile.txt and uses the Length property to display the size of the file in bytes.
Dim infoReader As System.IO.FileInfo
infoReader = My.Computer.FileSystem.GetFileInfo("C:\samplefile.txt")
MsgBox("File is " & infoReader.Length & " bytes.")
Use the GetFileInfo method to return a FileInfo object for the file, which can be queried for information. This example gets a FileInfo object for Testfile.txt and uses the Length property to display the size of the file in bytes.
Dim infoReader As System.IO.FileInfo
infoReader = My.Computer.FileSystem.GetFileInfo("C:\samplefile.txt")
MsgBox("File is " & infoReader.Length & " bytes.")
No comments:
Post a Comment