开发者

Is this the correct way to get file's size?

开发者 https://www.devze.com 2023-04-06 20:59 出处:网络
I have retrieved all file names and store it to a string array. Following is the code: Dim fi As System.IO.FileInfo

I have retrieved all file names and store it to a string array. Following is the code:

Dim fi As System.IO.FileInfo
Dim file_size As Int32
'all file names are stored in Files string array
Dim Fi开发者_开发问答les() As String
Dim CurrentFile As String

For Each CurrentFile In Files
    fi = New System.IO.FileInfo(CurrentFile)
    file_size = fi.Length
Next

Is this the correct way of getting each file's size? Is there any better way to get file size? I have thousand of files and I'm looking for a better approach.


Yes the FileInfo classes Length Property gives you the size of the file in bytes.

FileInfo Description MSDN

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号