2

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

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);
    }
}

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.

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

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

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.

What am I doing wrong?

Bypp
  • 331
  • 3
  • 22
  • Duplicate of http://stackoverflow.com/questions/24144003/get-available-disk-space-in-unity – Endrju Jun 16 '14 at 23:31
  • Not a duplicate, the other question is looking for an alternative solution to my problem since the method used above isn't working right for me. This question is an update showing the exact problem I'm having with this method after more testing. I believe it is more specific and not entirely the same question, thus why I made another question. – Bypp Jun 17 '14 at 12:52

1 Answers1

2

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

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

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

Bypp
  • 331
  • 3
  • 22
  • Will mark this as correct, but in case I might be wrong, feel free to post your own answer, or add to this one. – Bypp Jun 19 '14 at 18:57