vb获取大文件的大小

2025-02-23 21:01:45
推荐回答(4个)
回答1:

有时API确实很好很强大。。。但是,VB可以做的事情,从来就不需要别人。
输入文件路径,即可返回文件的字节大小!

'BY Coo_boi
Private Function GetFileVolume(ByVal lpFileName As String) As Long
If Dir(lpFileName) = "" Then Exit Function
Dim FF As Long
FF = FreeFile()

Open lpFileName For Binary Access Read As #FF
GetFileVolume = LOF(FF)
Close #FF
End Function

回答2:

  工程-引用-Microsoft scripting runtime后;

  Private Sub Form_Load()
  Dim fso1 As New FileSystemObject
  Dim folder1 As Folder
  Set folder1 = fso1.GetFolder("c:\")
  Msgbox folder1.Size & "Bytes"
  End Sub

回答3:

Dim infoReader As System.IO.FileInfo
infoReader = My.Computer.FileSystem.GetFileInfo("C:\testfile.txt")
MsgBox("File is " & infoReader.Length & " bytes.")

回答4:

double貌似比long可以大很多。
获取文件句柄貌似可以用API - CreateFile,你自己试试