CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    May 2001
    Location
    South Africa
    Posts
    6

    Determining file size in VB

    How do I determine the size of any file in a certain directory? (In VB 6.0)



  2. #2
    Join Date
    Aug 2000
    Location
    KY
    Posts
    766

    Re: Determining file size in VB

    the filelen(filename) function will give up the size of the file
    filedatetime will give the date and time last modified.



  3. #3
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: Determining file size in VB

    '1 filelistbox
    '1 command button
    'select a file from file list box, then click on command button

    Option Explicit

    Private Sub Command1_Click()
    Dim lngFileSize As Long
    lngFileSize = FileLen(File1.FileName)
    MsgBox "File Size: " & Format(lngFileSize, "###,###,### bytes")
    End Sub


    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, Bruno Paris and all the other wonderful people who made and make Codeguru a great place. Come back soon, you Gurus.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  4. #4
    Join Date
    Mar 1999
    Location
    Nepal
    Posts
    540

    Re: Determining file size in VB

    If it's an open file, you can use the LOF() function

    open "test.txt" for binary as #1
    msgbox LOF(1)
    close #1


  5. #5
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: Determining file size in VB

    Dim filesys,f As Object
    Set filesys = CreateObject("Scripting.FileSystemObject")
    Set f = filesys.GetFolder(folderpath)
    Msgbox f.Size



    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

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

Featured