WindowsGetDrives() not implemented in Unity 5.2 on Windows 10?

I need to traverse the file hierarchy, so I start by getting the drives like so:

string[] drives = System.Environment.GetLogicalDrives();

However, this gets me the following error:

Not implemented? Strange. So I do some poking around and find an answer back from 2010 that advocated using this line instead:

string[] drives = Directory.GetLogicalDrives();

However, this results in the exact same error! I can’t believe it’s simply “not implemented”, I mean, there are a few different threads around pointing to the one I linked above from several years ago, advocating this code as the correct and working solution.

Did something change in 5.2.1f1, or perhaps is it not set up to work for Windows 10? I’m at a loss.

Sounds like a Mono issue. Try changing the API compatibility to .Net 2.0.

2315148--156037--upload_2015-9-28_13-51-47.png

1 Like

That’s what I’m thinking.

Changing the API compatibility has the same error result.

Upon further investigation, the API calls I used are fully functional in a blank project in 5.1.2 without any problem, even on the 2.0 Subset compatibility level.

I tried doing a clean clone of my repository (since all the visual studio project files, library folder, etc are all ignored) and after regenerating everything it didn’t solve the problem. I guess the next step is to reimport everything into a fresh project and see what happens.

Bah! Never mind, the problem was actually linked to DriveInfo not being implemented, which I can easily work around. The line number blowing up in DriveInfo.cs just so happened to be a valid line in my own script. Damn dense stack traces!
I mean, I don’t know why making a DriveInfo would be unimplemented either, especially since it’s listed on the mono compatibility list, but oh well. Glad I didn’t have to waste a day on reimporting.

Thanks for your help, karl.

1 Like