开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜