calculating file size - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

calculating file size

y2keabley2keable Posts: 23Member
anyone know how to use qbasic to calculate the size of a .EXE file? Need to know its size so i can make a progress bar to say how much of it my setup program has copied.

cheers

Comments

  • the walrusthe walrus Posts: 249Member
    If the file is open you can use LOF([italic]filenumber[/italic]) to get the length of the file.

    : anyone know how to use qbasic to calculate the size of a .EXE file? Need to know its size so i can make a progress bar to say how much of it my setup program has copied.
    :
    : cheers

  • Folker FritzFolker Fritz Posts: 19Member
    This example only works for executable files. Every executable file has a part of the header where the filesize is stored. This is interesting when these files have attachments and you want to know the original size. I think the LOF() command is more usefull for you, but I post this code anyways.



    OPEN "qb.exe" FOR BINARY AS #1
    a$ = SPACE$(2)
    GET #1, 5, a$
    a& = ASC(MID$(a$, 1, 1))
    exesize& = a& * 512 - 512
    a& = ASC(MID$(a$, 2, 1))
    exesize& = exesize& + (a& * 256 * 512)
    GET #1, 3, a$
    a& = ASC(MID$(a$, 1, 1))
    exesize& = exesize& + a&
    a& = ASC(MID$(a$, 2, 1))
    exesize& = exesize& + (a& * 256)
    PRINT "Filesize should be:", exesize&
Sign In or Register to comment.