Search code examples
c#windowsdriveinfo

Check whether drive is main drive


I've got a DriveInfo object. I want to find out whether the drive is the Windows Drive(on my PC it's C:) because you can't right to the root directory of the Windows Drive.


Solution

  • You could use string path = Path.GetPathRoot(Environment.SystemDirectory); and than check agains the drive name, like C:\ or D:\, ...