|
#1
|
|||
|
|||
|
Convert MB to GB??
Hi!
In my Project I have the following code to show the drive's free space in a table: Code:
cSpFree = Drive.GetFreeSpace("C:");
cspace = Drive.GetSize("C:");
Label.SetText("cSpace", cSpFree.." MB");
Also, basically the same question for another part, Im using the following code to show the free memory: Code:
tbMemory = System.GetMemoryInfo();
Label.SetText("MemoryFree", tbMemory.AvailableRAM.." MB");
Thanks! ![]() This is part of a sorta quick access pannel I have made for my lappy to stay on top at the top of the screen with usefull shortcuts, mostly using the NirCmd command line app that was introduced to me from a thread on this forum which has helped me no end Last edited by SteevieNiteHeat; 2 Weeks Ago at 05:28 PM. Reason: typo's corrected |
|
#2
|
||||
|
||||
|
you need to divide the total by 1000 for gigs. Here's two ways you can do it.
Code:
cSpFree = Drive.GetFreeSpace("C:");
cspace = Drive.GetSize("C:");
GBspace=cspace/1000
GBFree = cSpFree/1000
if GBFree < 1
then
Label.SetText("cSpace", cSpFree.." MB out of "..GBspace.." free");
else
Label.SetText("cSpace", GBFree.." GB out of "..GBspace.." free");
end
Code:
function LeftOverMegs(Gigs,TotalMegs)
return Math.Round(TotalMegs - (Gigs*1000), 0);
end
cSpFree = Drive.GetFreeSpace("C:");
cspace = Drive.GetSize("C:");
GBspace =cspace/1000
GBFree = cSpFree/1000
TotalGigs = Math.Round(GBspace, 0);
FreeGigs = Math.Round(GBFree, 0);
TotalMegs = LeftOverMegs(TotalGigs,cspace)
FreeMegs = LeftOverMegs(FreeGigs,cSpFree)
Label.SetText("cSpace", FreeGigs.."GB and "..FreeMegs.."MB out of "..TotalGigs.."GB and "..TotalMegs.."MB free");
__________________
User error: replace user and press any key to continue. |
|
#3
|
|||
|
|||
|
Brilliant, thank you so much for your reply :-)
|
|
#4
|
||||
|
||||
|
Glad I could help
__________________
User error: replace user and press any key to continue. |
|
#5
|
||||
|
||||
|
Divide by 1024, not 1000.
(ie. 1 gigabyte = 1024 megabytes) |
|
#6
|
||||
|
||||
|
Doh, my bad. Thanks for catching that mystica. Not sure where my brain went to there..........
__________________
User error: replace user and press any key to continue. |
|
#7
|
||||
|
||||
|
Didn't anyone think of String.GetFormattedSize?
|
|
#8
|
||||
|
||||
|
__________________
User error: replace user and press any key to continue. |
![]() |
«
Previous Thread
|
Next Thread
»
| Thread Tools | |
| Display Modes | |
|
|
All times are GMT -6. The time now is 08:31 AM.










Linear Mode
