Click here to Skip to main content
15,902,739 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to set the selected path of the folder dialog box to a path of a flashdrive or hdd, let us say that its F: , but it still depends to the computer used right ? so that's my problem. The code that i've tried is working but what if its not F:

What I have tried:

folderBrowserDialog1.RootFolder = Environment.SpecialFolder.MyComputer;
folderBrowserDialog1.SelectedPath = @"f:\"
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
{
txtLocation.Text = folderBrowserDialog1.SelectedPath;
}
Posted
Comments
Richard MacCutchan 3-Jun-16 13:00pm    
Do not hard code these sort of parameters, since you do not know in advance whether that drive letter is valid: let the user choose.
Hikari18 4-Jun-16 3:02am    
okay, thank you for the reply :)
Philippe Mori 3-Jun-16 14:49pm    
I prefer to use open file dialog instead as old dialog don't show files...
Hikari18 4-Jun-16 3:02am    
thank you :)
Philippe Mori 4-Jun-16 7:30am    
This might interest you : get removable media drives list in c#

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