Results 1 to 7 of 7

Thread: need help please!!!!!

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2002
    Location
    CHILE
    Posts
    36

    Thumbs up 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:
    1. [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

  2. #2
    Frenzied Member pnish's Avatar
    Join Date
    Aug 2002
    Location
    Tassie, Oz
    Posts
    1,918
    Add a reference to the Microsoft Scripting Runtime and try this code:
    VB Code:
    1. Dim fso As FileSystemObject
    2. Dim fil As File
    3.  
    4. Set fso = New FileSystemObject
    5. Set fil = fso.GetFile("c:\hospital.mdb")
    6.  
    7. 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.

  3. #3

    Thread Starter
    Member
    Join Date
    Jul 2002
    Location
    CHILE
    Posts
    36

    resolved

    Thank pete, it's Ok

  4. #4
    Frenzied Member Shawn N's Avatar
    Join Date
    Dec 2001
    Location
    Houston
    Posts
    1,631
    Why not just use the LOF function?
    Please rate my post.

  5. #5
    Frenzied Member pnish's Avatar
    Join Date
    Aug 2002
    Location
    Tassie, Oz
    Posts
    1,918
    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.

  6. #6
    Frenzied Member Shawn N's Avatar
    Join Date
    Dec 2001
    Location
    Houston
    Posts
    1,631
    Eh, FileLen is the function I was thinking of. I think he'd be better off with that.
    Please rate my post.

  7. #7
    Frenzied Member pnish's Avatar
    Join Date
    Aug 2002
    Location
    Tassie, Oz
    Posts
    1,918
    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
  •  



Click Here to Expand Forum to Full Width