Search Unity

System.IO.DriveInfo works on Mac but not Win?

Discussion in 'Editor & General Support' started by Doug, Nov 6, 2008.

  1. Doug

    Doug

    Joined:
    Oct 19, 2007
    Posts:
    36
    The following code works on Mac:
    Code (csharp):
    1. DriveInfo[] allDrives = DriveInfo.GetDrives();
    And it correctly returns the single drive with the DriveInfo.Name of "/".

    However, on a standalone windows build, I get an exception instead:
    Code (csharp):
    1. NotImplementedException: The requested feature is not implemented.
    2. System.IO.DriveInfo.GetDrives ()
    I ran the following command on both systems:
    Code (csharp):
    1. print(System.Environment.Version);
    Both Mac Windows print out:
    Code (csharp):
    1. 2.0.50727.42
    Here is the msdn link for this for GetDrives() in the .Net Framework 2.0:
    http://msdn.microsoft.com/en-us/library/system.io.driveinfo.getdrives(VS.80).aspx

    I will also note that both of the following work fine:
    DirectoryInfo.GetDirectories()
    DirectoryInfo.GetFiles()

    What is going on here?
     
  2. Doug

    Doug

    Joined:
    Oct 19, 2007
    Posts:
    36
    FYI

    As a workaround, use this:

    Code (csharp):
    1. foreach (string drive in Directory.GetLogicalDrives() )