System.IO.DriveInfo返回错误的磁盘空间值 [英] System.IO.DriveInfo returns wrong disk space values

查看:233
本文介绍了System.IO.DriveInfo返回错误的磁盘空间值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新:我测试过的Android设备上未出现此问题.它返回良好的价值.非常感谢您对此事提出任何建议.

UPDATE : This issue doesn't appear on Android devices I've tested. It returns good values. Would really appreciate any pointers on this matter.

我无法从Mac台式计算机上获取正确的AvailableFreeSpace值.我正在使用Unity3D C#,并且正在使用以下代码:

I am having trouble getting the correct AvailableFreeSpace values from my Mac desktop computer. I am working with Unity3D C#, and am using the following code :

DriveInfo[] drives = DriveInfo.GetDrives();

foreach(DriveInfo drive in drives)
{
    if (drive.IsReady)
    {
        Debug.Log(drive.Name);
        Debug.Log(drive.AvailableFreeSpace);
        Debug.Log(drive.TotalFreeSpace);
        Debug.Log(drive.TotalSize);
    }
}

我的结果有点奇怪.我只得到一个驱动器:我得到的名称是"/",并且值错误. AvailableFreeSpace返回的值比TotalSize高,这没有任何意义.另外,如果有帮助,则DriveType为Unknown,驱动器Format为unixfs.

My results are a bit weird. I'm only getting one drive : The name I'm getting is "/", and ythe values are wrong. AvailableFreeSpace returns a higher value than TotalSize, which makes no sense. Also, the DriveType is Unknown and the drive Format is unixfs, if that helps.

也许我不知道我是否缺少有关Mac计算机上文件结构的明显信息?

Don't know if I'm missing something obvious about the file structure on a Mac computer, maybe?

我有一个500go的SATA硬盘,分为两个分区.它不应该给我2个驱动器吗?

EDIT : I have a SATA HDD with 500go divided into two partitions. Shouldn't it give me 2 drives?

我的Monodevelop版本为4.0.1,所以我认为这与几年前在2.10.0版或类似版本上报告的错误无关.

EDIT2 : My Monodevelop version is 4.0.1, so I don't think this is related to the bug reported years ago on version 2.10.0 or something like that.

我在做什么错了?

推荐答案

发布到另一个论坛,显然这是Mono/Unity错误.最新版本的Unity使用旧的Mono(编译器,而不是MonoDevelop(文本编辑器)):

Posted to another forum, and apparently this is a Mono/Unity bug. The newest version of Unity uses an old Mono (the compiler, not MonoDevelop (the text editor)) :

http://unity3d.com/unity/faq#section-445

在更高版本的Mono(2.10)中修复了返回错误值的错误,在Mono 3.0版中还修复了与DriveInfo有关的另一个错误:

The bug returning incorrect values was fixed in a later version of Mono (2.10) and another bug concerning DriveInfo was also fixed in Mono version 3.0 :

http://www.mono-project.com/Release_Notes_Mono_2.10

http://www.mono-project.com/Release_Notes_Mono_3.0

因此,除了寻找另一种获取Mac上可用磁盘空间的方法外,几乎没有其他事情要做.

So there's pretty much nothing to do except find another way to get the available disk space on a Mac.

这篇关于System.IO.DriveInfo返回错误的磁盘空间值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆