kamleshmistry
asked on
how to i get the size in bytes of a file in vb.net
how do i get the size of a file?
system.file.io.files.getat
ASKER
not bad, but how do I get the size of a particular file, provided I know the path
Input: file path
Output: file size...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
that is correct.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
timbo why open the file when you dont have to ?
If you're using a method that takes in a Stream, it will provide the stream and the file size. Considering he has one specific file, I have a feeling he's going to open it anyways.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
from MSDN:
' The following example displays the names and sizes
' of the files in the specified directory.
Imports System
Imports System.IO
Public Class FileLength
Public Shared Sub Main()
' Make a reference to a directory.
Dim di As New DirectoryInfo("c:\")
' Get a reference to each file in that directory.
Dim fiArr As FileInfo() = di.GetFiles()
' Display the names and sizes of the files.
Dim f As FileInfo
Console.WriteLine("The directory {0} contains the following files:", di.Name)
For Each f In fiArr
Console.WriteLine("The size of {0} is {1} bytes.", f.Name, f.Length)
Next f
End Sub 'Main
End Class 'FileLength