DigDeep

DriveSpace

5 posts in this topic

#1 ·  Posted

Not sure what am I doing wrong here...

If less than 50GB then the 1st one. If less than 1023MB then 2nd one, else if more than 50GB then 3rd one.

Can someone please fix this?

$FreeSpace = DriveSpaceFree(@HomeDrive & "\")

If _ShowBytes($FreeSpace) < 50 & ' GB' Then
    MsgBox(0, '', 'Less Than 50 GB')

ElseIf _ShowBytes($FreeSpace) < 1023 & ' MB' Then
    MsgBox(0, '', 'Less Than 1023 MB')

Else ; More than 50 GB
    MsgBox(0, "", _ShowBytes($FreeSpace))
EndIf

Func _ShowBytes($bytes)
    Local $x, $bytes_suffix[2] = [" MB", " GB"]
    While $bytes > 1023
        $x += 1
        $bytes /= 1024
    WEnd
    Return Round($bytes) & $bytes_suffix[$x]
EndFunc   ;==>_ShowBytes

 

Share this post


Link to post
Share on other sites



#3 ·  Posted

thanks @benners

Share this post


Link to post
Share on other sites

#4 ·  Posted

@benners just curious why you feel the need to do your division and then tack on ^ 1? Completely unnecessary.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#5 ·  Posted

Yep you're right. It was from some old code I had that that went MB GB TB etc, so the 1024 was rooted  accordingly so I just copied and pasted. :>

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now