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.
Asked
Active
Viewed 84 times
0
-
3It depends what you mean by the "main drive". It sounds like you actually want to check the permissions. – SLaks Jul 19 '15 at 19:36
-
Agree with SLaks. What is the ultimate goal of your program? – siride Jul 19 '15 at 19:37
-
To write to the root directory of the drive and if it's the main drive then write it to AppData – trinalbadger587 Jul 19 '15 at 19:48
-
1I think there's a lot more context missing, but that sounds not unreasonable. – siride Jul 19 '15 at 19:50
1 Answers
1
You could use string path = Path.GetPathRoot(Environment.SystemDirectory);
and than check agains the drive name, like C:\
or D:\
, ...

BendEg
- 20,098
- 17
- 57
- 131
-
I have that in one of my programs and I was wondering if there was a better way of doing it but thanks. – trinalbadger587 Jul 19 '15 at 19:36