|
-
Mar 2nd, 2004, 07:35 PM
#1
Thread Starter
Member
need help please!!!!!
Hi, I've Hospital.mdb file in drive c:\ and I need to know the file size.
How could I do it?
I'm trying with:
VB Code:
[COLOR=darkblue]Public Declare Function [/COLOR] GetFileSize Lib "kernel32" ([COLOR=darkblue]ByVal[/COLOR] hFile [COLOR=darkblue]As Long[/COLOR] , lpFileSizeHigh [COLOR=darkblue]As Long[/COLOR] ) [COLOR=darkblue]As Long[/COLOR]
but I don't know how do it
any suggestion
-
Mar 2nd, 2004, 07:57 PM
#2
Add a reference to the Microsoft Scripting Runtime and try this code:
VB Code:
Dim fso As FileSystemObject
Dim fil As File
Set fso = New FileSystemObject
Set fil = fso.GetFile("c:\hospital.mdb")
MsgBox "File is " & fil.Size & " bytes"
There are other ways to get a file's size but I find the FileSystemObject simple & convenient, plus there's quit a bit of other info it can give you.
To use the GetFileSize api, you need to pass the handle of the file and I'm not sure how to get that info.
Hope this helps
Pete
No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.
-
Mar 2nd, 2004, 08:08 PM
#3
Thread Starter
Member
-
Mar 2nd, 2004, 08:17 PM
#4
Frenzied Member
Why not just use the LOF function?
-
Mar 2nd, 2004, 08:35 PM
#5
Originally posted by Shawn N
Why not just use the LOF function?
Using LOF requires that the file is open. That may not always be desirable or possible, especially in the case of a database which may already be opened exclusively.
Pete
No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.
-
Mar 2nd, 2004, 08:41 PM
#6
Frenzied Member
Eh, FileLen is the function I was thinking of. I think he'd be better off with that.
-
Mar 2nd, 2004, 09:02 PM
#7
Yeah... I'd totally forgotten about FileLen. It certainly saves a few lines of code and the overhead associated with FSO.
Just as an aside, MSDN describes those functions (LOF, FileLen etc) as legacy and that they will eventually be phased out in favour of the File System Object model. But... they're still in VB6, so why not use 'em.
Pete
No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|