Click here to Skip to main content
15,901,505 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi All,

I have some path like "programfiles\Test\test.xml".

I need to check in which drive the given path exists.

for example if the given the path exists in "C" drive then i need to return C drive .

How to achieve,Is there any functionality in C# through which we can achieve this.
Posted

1 solution

No - you would have to do it manually, by checking each drive in turn.

C#
DriveInfo[] drives = DriveInfo.GetDrives();
Will list all those available to you, and the drives[n].Name property will give you the "C:\" part so you can use Path.Combine to form a complete path for testing.
 
Share this answer
 
Comments
Rob Philpott 16-Apr-14 10:55am    
Splendid, splendid.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900