Click here to Skip to main content
15,888,018 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hi ,

I am getting the below error while trying to get the path.

My code is below:

C#
if (!Directory.Exists(Path.GetDirectoryName(Application.ExecutablePath) + "\\Daily_File"))
                Directory.CreateDirectory(Path.GetDirectoryName(Application.ExecutablePath) + "\\Daily_Files");



Error 71 'System.Web.HttpApplicationState' does not contain a definition for 'ExecutablePath' and no extension method 'ExecutablePath' accepting a first argument of type 'System.Web.HttpApplicationState' could be found (are you missing a using directive or an assembly reference?)

Thanks in advance
Posted

1 solution

Try Server.MapPath("~") or HttpContext.Current.Request.PhysicalApplicationPath.ToString()
 
Share this answer
 
Comments
neha427 19-Jul-11 5:02am    
Hi Prerak ,
Thank you.It works.
But do you have any idea about what is the problem with Executable path?
Thanks
Prerak Patel 19-Jul-11 5:30am    
You are welcome Neha.
As error says - 'System.Web.HttpApplicationState' does not contain a definition for 'ExecutablePath'
It is not there for web applications.

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