Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default File length of large files

Hello,

I have a problem retrieving file length of large files greater then 2 GB
using function FileLen(strFileName). This function returns long values with 4
Byte, delivering negative values for file size above 2 GB and recycles above
4 GB.
Is there another way to retrieve the filesize in excel working for large
files.
I have a list of filenames in Excel and need to do some calculations and
reporting on the filesize.
Any help appreciated. Thanks.

Stefan Hoyos
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default File length of large files

For reliable results on large file, resort to the API calls.
Example from the API-Guide, http://www.allapi.net/

Private Const GENERIC_READ = &H80000000
Private Const FILE_SHARE_READ = &H1
Private Const OPEN_EXISTING = 3

Private Declare Function CreateFile Lib "kernel32" Alias "CreateFileA"
(ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal
dwShareMode As Long, lpSecurityAttributes As Any, ByVal
dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal
hTemplateFile As Long) As Long
Private Declare Function GetFileSizeEx Lib "kernel32" (ByVal hFile As Long,
lpFileSize As Currency) As Boolean
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long)
As Long

Private Sub CommandButton1_Click()

Dim hFile As Long, nSize As Currency, sSave As String

'open the file
hFile = CreateFile("c:\autoexec.bat", GENERIC_READ, FILE_SHARE_READ, ByVal
0&, OPEN_EXISTING, ByVal 0&, ByVal 0&)
'get the filesize
GetFileSizeEx hFile, nSize

'close the file
CloseHandle hFile

MsgBox "File Size:" + Str$(nSize * 10000) + " bytes"

End Sub

NickHK

"Stefan Hoyos" <Stefan wrote in message
...
Hello,

I have a problem retrieving file length of large files greater then 2 GB
using function FileLen(strFileName). This function returns long values

with 4
Byte, delivering negative values for file size above 2 GB and recycles

above
4 GB.
Is there another way to retrieve the filesize in excel working for large
files.
I have a list of filenames in Excel and need to do some calculations and
reporting on the filesize.
Any help appreciated. Thanks.

Stefan Hoyos



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Linked Files cause large file sizes when saved Steve[_24_] Excel Worksheet Functions 0 February 25th 10 12:49 AM
how to split a large excel file into multiple smaller exel files. RM Excel Discussion (Misc queries) 2 February 17th 10 10:13 PM
Converting Large XML Files into CSV File via Excel DaleB Excel Discussion (Misc queries) 2 December 5th 07 02:14 PM
How do I break a large .CSV file into several small Excel files? Grand Blanc Campbell Excel Worksheet Functions 9 September 3rd 06 03:17 AM
How do I sort a large column of data by length? blange Excel Worksheet Functions 3 May 29th 06 08:35 PM


All times are GMT +1. The time now is 12:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"