Click here to Skip to main content
15,915,019 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey guys,
I've got a Project where I want to select a file in my Windows Explorer and use the path of this file in C#.
Is there any opportunity to get this path?
Posted
Comments
Kuthuparakkal 8-Aug-13 3:58am    
Post code sample from where you try to fetch file/its contents...
Also is this Windows app or console app ?

C#
System.Windows.Forms.OpenFileDialog ofd;
if (ofd.ShowDialog() == DialogResult.OK)
{
        string File = ofd.FileName;
}


[supplemental]
As per your request with adding the reference:
See help article (scroll down a little bit, you'll see)
it will help you with adding the reference,
[/supplemental]

Cheers,
Edo
 
Share this answer
 
v2
Comments
[no name] 8-Aug-13 4:20am    
Good
First thanks a lot :)
But do I need any assembly for that? because my compiler give me an error.
 
Share this answer
 
Comments
TrollTier 8-Aug-13 4:22am    
You need the System.Windows.Forms assembly.
It's listed in the .Net tab in the references.
Joezer BH 8-Aug-13 4:34am    
See help article (scroll down a little bit, you'll see)
it will help you with adding the reference,

BTW: you posted a second solution instead of clicking the Improve question link

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