0

我已检索所有文件名并将其存储到字符串数组中。以下是代码:

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

这是获取每个文件大小的正确方法吗?有没有更好的方法来获取文件大小?我有数千个文件,我正在寻找更好的方法。

4

1 回答 1

2

是的,FileInfo 类的 Length 属性为您提供了文件的大小(以字节为单位)。

FileInfo 说明 MSDN

于 2011-09-22T10:14:49.390 回答