I've been trying out the most of the Enviroment.SpecialFolder enumeration, but I think there isn't any way of what I'd like to accomplish with the enumeration only. Using the string.Substring() method brought me the farest, yet.
I try to get just the system partition path, where windows is actually installed. On machine A it might be C:\, on machine B it might be D:\.
The most sufficent solution, I found so far was
var path = Environment.GetFolderPath(Environment.SpecialFolder.Windows)
.Substring(0, 3);
Is there a better way to do this? Thanks.
To get the drive, use Path.GetPathRoot. See http://msdn.microsoft.com/en-us/library/system.io.path.getpathroot.aspx
var root = Path.GetPathRoot(Environment.GetFolderPath(Environment.SpecialFolder.Windows));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With