Click here to Skip to main content
15,890,609 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how i can get file path on solution explorer in windowsform at runtime.I have to give a path of a from at windowsapplication1
Posted

1 solution

Application.StartupPath

or

System.Reflection.Assembly.GetExecutingAssembly().Location
 
Share this answer
 
Comments
maheshbisht 12-May-13 15:11pm    
like this => Application.StartupPath+"winform.cs"
Ron Beyer 12-May-13 15:16pm    
No, the forms are compiled into the main application, so they do not exist with the executable itself. If you need the location of the file that created the form, that's something different and isn't very useful at run time, can you explain what you are trying to do with this information?
maheshbisht 12-May-13 15:21pm    
actually i was working on report viewer and at run time i need a path of my report file .It's on solution explorer directly attached to winFormappliction1.
Ron Beyer 12-May-13 15:24pm    
If the report file is set to copy to the output directory, then you can use the above in something like Application.StartupPath + "\\ReportName.rpt" to get the report, if it's compiled with the application as an embedded resource or content, then its stored inside the executable and you will have to get it out using manifest resource manipulation. Out of curiosity though, why hard code that stuff and not just have an OpenFileDialog and let the user select the report location in case it changes?

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