這段代碼有什麼問題?我可以得到正確的價值? DrvUsg總是變爲零。請幫我拿這個代碼工作。幫我得到這段代碼工作
Computer cmp = new Computer();
string SysDrv = System.Environment.SystemDirectory.Substring(0, 2);
UInt64 TotalDrv = Convert.ToUInt64(cmp.FileSystem.GetDriveInfo(SysDrv).TotalSize/1024/1024);
UInt64 FreeDrv = Convert.ToUInt64(cmp.FileSystem.GetDriveInfo(SysDrv).AvailableFreeSpace/1024/1024);
UInt64 UsedDrv = (TotalDrv - FreeDrv);
UInt64 DrvUsg = Convert.ToUInt64((UsedDrv/TotalDrv) * 100);
TrkDrvUsg.Value = (int)DrvUsg;
LblDrvUsg.Text = (String.Format("System drive usage: {0}%", DrvUsg));
這是一個非常惡臭的整數除法惡臭。 – BoltClock 2011-03-12 05:02:40