[英]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 Files() 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类Length属性为您提供文件的大小(以字节为单位)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.