精通
英语
和
开源
,
擅长
开发
与
培训
,
胸怀四海
第一信赖
you've got a super-cool piece of software there! Gave me good insight into things I have been slow on working through sofar.你有一个超酷的软件! 给了我很好的洞察事物能力,到现在我一直在缓慢的工作才有所进展。
One problem though:一个问题:
My Kingston DataTraveler reports 7GB in your app, where in fact it has 8GB.我的金斯敦DataTraveler报告7 gb在你的应用,事实上它有8 gb的地方。
Hi, if you look at UsbDisk.cs, there's a FormatByteCount method at the bottom. This takes a number of bytes and generates a string description, converting it to KB, MB, or GB as appropriate. The result is rounded down to the nearest whole value. So your USB device must slightly less than 8GB and it's rounding down to 7GB. Being just a demo, I couldn't know who would want exactly what. But obviously it's quite easy to customize for your needs.
你好,如果你看看UsbDisk.cs,在底部有个FormatByteCount方法。 它采用字节数,生成一个字符串描述,将它转换为KB,MB或GB。 结果是四舍五入到最近的整值。 所以你的USB设备肯定略低于8gb,自然舍入成了7 gb。 仅仅是一个演示,我不知道是谁想要什么。 但显然很容易定制您的需求。
thank you for the quick reply! It took only minutes to modify and get the correct return. You are right btw, the DataTeveler has indeed slightly less than 8GB, a fact that I have not been aware before!
谢谢你的快速回复! 花了几分钟来修改并得到正确的回报。 你对,顺便说一句,DataTeveler的确略低于8 gb,之前我没有意识到一个事实!
May i know how to make it to get the correct return?我可以知道如何使它得到正确的回报呢?
The USbManager FreeSpace and Size properties do return the correct values. These are exact byte counts.USbManager FreeSpace和大小属性做返回正确的值。 这些都是精确的字节数。
The ToString method is what we're talking about in the article demo. If you don't want the ToString method to round-off the values to the nearest KB, MB, or GB and always want to return the exact Byte count then simply change the ToString method to not call the FormatByteCount method.
ToString方法在本文我们讨论演示。 如果你不想ToString方法舍入值到最近的KB,MB或GB和总是想返回的字节数,那么简单地改变ToString方法不调用FormatByteCount方法。
thx !I get a more accurate return too by modify it to 谢谢! 我也得到一个更准确的返回修改
private string FormatByteCount(float bytes)
{
string[] Suffix = { "B", "KB", "MB", "GB", "TB" };
int i;
double dblSByte=0;
for (i = 0; (int)(bytes / 1024) > 0; i++, bytes /= 1024)
dblSByte = bytes / 1024.0;
return String.Format("{0: 0.00} {1}", dblSByte, Suffix[i]);
}
thank you for the quick reply! It took only minutes to modify and get the correct return. You are right btw, the DataTeveler has indeed slightly less than 8GB, a fact that I have not been aware before!
谢谢你的快速回复! 花了几分钟来修改并得到正确的回报。 你有对的一面,顺便说一句,DataTeveler的确略低于8 gb,之前我没有意识到一个事实!
This may be because of the file system, when formatting a drive the actual file system will use a small amount for itself.这可能是因为文件系统,当格式化磁盘时,文件系统将使用少量空间。