这段代码有什么问题?我可以得到正确的价值? 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