Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

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

Discussion in 'Editor & General Support' started by ketura, Sep 28, 2015.

  1. ketura

    ketura

    Joined:
    Oct 2, 2013
    Posts:
    29
    I need to traverse the file hierarchy, so I start by getting the drives like so:

    Code (CSharp):
    1. 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:

    Code (CSharp):
    1. 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.
     
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,850
    Sounds like a Mono issue. Try changing the API compatibility to .Net 2.0.

    upload_2015-9-28_13-51-47.png
     
    ketura likes this.
  3. ketura

    ketura

    Joined:
    Oct 2, 2013
    Posts:
    29
    That's what I'm thinking.

    Changing the API compatibility has the same error result.
     
  4. ketura

    ketura

    Joined:
    Oct 2, 2013
    Posts:
    29
    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.
     
  5. ketura

    ketura

    Joined:
    Oct 2, 2013
    Posts:
    29
    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.
     
    karl_jones likes this.