Как можно опредилить размер файла на жестком диске?
заранне спасибо за ответ...
Private Declare Function GetFileSize Lib "kernel32" (ByVal hFile As Long, lpFileSizeHigh As Long) As Long
Private Declare Function lopen Lib "kernel32" _
Alias "_lopen" _
(ByVal lpPathName As String, _
ByVal iReadWrite As Long) As Long
Private Const OF_CANCEL = &H800
Private Const OF_CREATE = &H1000
Private Const OF_DELETE = &H200
Private Const OF_EXIST = &H4000
Private Const OF_PARSE = &H100
Private Const OF_PROMPT = &H2000
Private Const OF_READ = &H0
Private Const OF_READWRITE = &H2
Private Const OF_REOPEN = &H8000
Private Const OF_SHARE_COMPAT = &H0
Private Const OF_SHARE_DENY_NONE = &H40
Private Const OF_SHARE_DENY_READ = &H30
Private Const OF_SHARE_DENY_WRITE = &H20
Private Const OF_SHARE_EXCLUSIVE = &H10
Private Const OF_VERIFY = &H400
Private Const OF_WRITE = &H1
Private Const HFILE_ERROR = -1
Private Const FILE_BEGIN = 0
Private Const FILE_CURRENT = 1
Private Const FILE_END = 2
Private Declare Function lclose Lib "kernel32" _
Alias "_lclose" (ByVal hFile As Long) As Long
Private fso As New FileSystemObject
Public Function FileSize(FilePath As String) As Double
Dim Pointer As Long
Dim lpFSHigh As Long 'старший разряд
Dim lpFSLow As Long 'младший
Dim fso As New FileSystemObject
On Error Resume Next
Err.Clear
Pointer = lopen(FilePath, OF_READ)
If Pointer < 0 Then
Err.Clear
'специально сделано для зашифрованных не очень больших файлов
If fso.FileExists(FilePath) Then
FileSize = fso.GetFile(FilePath).Size
End If
Err.Clear
Exit Function
End If
'e = Err.LastDllError
'If e <> 0 Then Exit Function
lpFSLow = GetFileSize(Pointer, lpFSHigh)
If lpFSLow >= 0 Then
FileSize = lpFSLow
Else
FileSize = 2 ^ 32 + lpFSLow
End If
FileSize = FileSize + 2 ^ 32 * lpFSHigh
lclose Pointer
End Function
Alexanbar писал(а):Нечего хранить такие большие файлы Шутка.
Сейчас этот форум просматривают: AhrefsBot, Yandex-бот и гости: 27