0

I'm currently using Unity3D, and using C# as my main script language. My application downloads some assets from a server, and I need to make sure there is enough space available for this. My assets are going in the path that is given by Application.persistentDataPath.

I need to check this for a Mac Standalone build !

Would anyone know how to check this, preferably in Unity C#, but I can work with native code and such if I have to !

UPDATE :

Upon seeing the answer from @Marius George, I'm just wondering about a little detail : That methods gives me information on all drives. What I need is information for my app only, and not necessarily all the drives (my application might not have access to all of the disk space). Any ideas how to get the one drive I actually need?

Bypp
  • 331
  • 3
  • 22

1 Answers1

1

I think the System.IO.DriveInfo class works on some platforms:

http://forum.unity3d.com/threads/disk-space-available.119725/

See if this works on Mac.

Marius George
  • 526
  • 2
  • 6
  • Yep, that works on Mac. Something like: Debug.Log(new System.IO.DriveInfo("/").AvailableFreeSpace); – Khakionion Jun 14 '14 at 02:06
  • I've seen this, however it doesn't appear to work in the Unity3D editor as it says "NotImplementedException:The requested feature is not implemented". Would it work in a standalone build for Mac ? – Bypp Jun 16 '14 at 12:51
  • Did you try the ("/") option as shown by Khakionion? Maybe that works on the current drive on which your application is installed. – Marius George Jun 16 '14 at 15:39
  • I did try that, however I'm not sure the values returned are right... Somehow the AvailableFreeSpace is higher than the TotalFreeSpace, and even higher than the TotalSize... and the values are not right according to what I'm seeing on my test device. Maybe I'm getting something wrong ? (The value returned is in bits, correct? I've doubled checked with bits and bytes conversions and it doesn't seem to be right in either case) – Bypp Jun 16 '14 at 20:23
  • Just checked (don't know why I missed it before), the returned value is in bytes. However, the values are still wrong somehow. Maybe I'm missing something obvious about hard drives ? – Bypp Jun 16 '14 at 20:25
  • Created another question for this new problem : http://stackoverflow.com/questions/24252100/system-io-driveinfo-returns-wrong-disk-space-values , I'll accept your answer but would appreciate it if you guys could take a look at it ! Thanks again. – Bypp Jun 16 '14 at 21:28
  • No one has answered further on my last question, updated a couple things. Would appreciate some input from you guys :) – Bypp Jun 18 '14 at 19:49
  • I was digging around a bit regarding bugs in the implementation of DriveInfo on some platforms, and found some posts a few years old. Nothing else came up that is very recent. – Marius George Jun 18 '14 at 20:25