Results 1 to 8 of 8

Thread: DISKFREESPACE?

  1. #1

    Thread Starter
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538

    Talking

    Probably an easy one, but using the getdiskfreespace or getdiskfreespaceex functions returns a value of "4082760192".

    How do all you guys (and girls) show this as "4.1GB" for example in your apps?

    Thank you!
    Alex Read

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  2. #2
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    It returns the number of BYTES on the HD, not MB or GB. To convert, use this:

    Code:
    Function FreeMB() As long
       FreeMB = GetDiskFreeSpace("C") / 1024
    End Function
    I know that's not how to use getdiskfreespace, but you get the idea.

    FreeMB = GetDiskFreeSpace / 1024
    FreeGB = FreeMB /1000

    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  3. #3
    Hyperactive Member gravyboy's Avatar
    Join Date
    Jan 2000
    Location
    Where I was before . . . if you don't know then you're new!
    Posts
    334

    BYTE ME!

    The value is the number of bytes

    val/1024 = kb
    val/1024^2=mb
    val/1024^3=gb etc

    even better you can format the final value

    Code:
    val=format(val,"##,##0.00")
    gives xx,xxx.xx!
    Matt G
    VS6 Ent SP5 @ Work
    VS6 Ent SP5 & VB.Net @ Home
    [email protected]



  4. #4

    Thread Starter
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    Thank you everyone!

    Appriciate you writing back. Just one thing, Gravyboy "Byte Me" is this the worst pun we have seen on this site?

    Thank you once again!

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  5. #5
    Hyperactive Member gravyboy's Avatar
    Join Date
    Jan 2000
    Location
    Where I was before . . . if you don't know then you're new!
    Posts
    334

    Pun Frenzy!

    Alex,

    It may well be! GetFreeDiskSpaceEx is the one to use as it has additional abilities, can't remember what they are but they are there!
    Matt G
    VS6 Ent SP5 @ Work
    VS6 Ent SP5 & VB.Net @ Home
    [email protected]



  6. #6

    Thread Starter
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538

    Smile leads me to another question

    I noticed quite a few have the ex on, not just withgetdiskfreespace. Why? they do the same function, call on the same dll's. What's the advantage?

    Thank you,
    confused.

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  7. #7
    Hyperactive Member gravyboy's Avatar
    Join Date
    Jan 2000
    Location
    Where I was before . . . if you don't know then you're new!
    Posts
    334

    MSDN

    Windows 95 OSR2 and later:
    The GetDiskFreeSpaceEx function is available on Windows 95 systems beginning with OEM Service Release 2 (OSR2). The GetDiskFreeSpaceEx function returns correct values for all volumes, including those that are greater than 2 gigabytes.
    That's from MSDN April 99.
    Matt G
    VS6 Ent SP5 @ Work
    VS6 Ent SP5 & VB.Net @ Home
    [email protected]



  8. #8

    Thread Starter
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538

    Wink ohhhhhh,

    Thank you once again. So the main reason is the operability on a wider range of operating systems.

    You learn something new every day!
    Thank you.

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

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