3

UPDATE : I have found a solution for the iOS and Android versions, however, I'm still getting this error when building for Mac and Windows. I've seen a workaround that only gets me the name of the drives :

foreach (string drive in Directory.GetLogicalDrives());

... But that doesn't get me anywhere in terms of free space.

ORIGINAL QUESTION :

I am working in Unity C#.

I'd like to get the free available disk space on the device I'm using. I've tried using System.IO.DriveInfo but it doesn't work as I receive:

NotImplementedException: The requested feature is not implemented.

...when I try to get the drives. I think this is only a Windows problem, but I haven't found a solution doing my research. I'm also wondering if this class will work on Android, iOS and Mac as well.

DriveInfo[] allDrives = DriveInfo.GetDrives();

Why is this not working? And is there a better solution that would work on all platforms?

Bypp
  • 331
  • 3
  • 22
  • IMO if you shouldn't need that info in a game in the first place. When you create/modify files check that they have been properly created by responding to the corresponding exceptions. Other than that, there's probably not a common reliable solution because apps can be sandboxed (even on desktop operating systems) and thus results may not be actual disk space but for instance merely a quota reserved for the app. – CodeSmile Jun 10 '14 at 15:54
  • Is the a Silverlight app? Or a Windows Form or Web app? – simon at rcl Jun 10 '14 at 16:14
  • It's an app that will eventually be on all devices mentionned above (Windows standalone, Mac standalone, iOS, Android). @LearnCocos2D what would be the corresponding exceptions then ? – Bypp Jun 10 '14 at 17:00
  • Quick update : my main priority right now is to get this working on Mac, was wondering if anyone had any particular pointers for this ? Do I have to use a plugin, work with XCode ? I'm in the dark here... – Bypp Jun 13 '14 at 15:05
  • Why do you want this information? – Nick Udell Jul 29 '14 at 11:01
  • 3
    the answer to "why" is obvious, say your app downloads videos or whatever - anything really. an universal solution would be appreciated. – Lassi Kinnunen Jul 28 '17 at 11:16

0 Answers0