[ACCEPTED]-How do you detect the main hard drive letter such as C: drive?-c#
Accepted answer
Try
Path.GetPathRoot(Environment.GetFolderPath(Environment.SpecialFolder.System));
That will return (normally) C:\
But it 3 depends on how you define the "main" hard 2 drive. This will give you the drive Windows 1 is installed on.
This should work (assuming you want the 1 drive that windows is on):
string rootDrive = Path.GetPathRoot(Environment.SystemDirectory);
"SystemDrive" is the environment variable 1 on XP that you want.
var d = Directory.GetDirectoryRoot(Environment.GetEnvironmentVariable("windir"));
0
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.