in the WCF called in Server.MapPath Get Service Publishing directory path
in the WCF called in Server.MapPath Get Service Publishing directory path
in the WCF want to use the Server.map gets the absolute path to the current service publishing directory. However, when debugging, it is found that:
"System.Web.HttpContext.Current.Server.MapPath (" ... "+ filename);
"when not turned onASP when compatible mode (aspnetcompatibilityenabled= "true") , WCF does not support HttpContext, HttpApplication, most articles suggest modifications < serviceHostingEnvironment aspnetcompatibilityenabled= "true" > enables WCF to use ASP. NET Traditional practices. "
Finally, there are two ways to resolve this:
string T1 = System.Web.HttpContext.Current.Server.MapPath ("~");
// the above-mentioned wording WCF not open aspnetcompatibilityenabled when the
// will because HttpContext.Current = = NULL error occurred ???????
String t2 = System.Web.Hosting.HostingEnvironment.MapPath ("~");
The above notation is not a problem with WCF
1. application.startuppath--gets the path to the executable file that launched the application, not including the name of the executable file.
2. environment.currentdirectory--gets and sets the fully qualified path to the current directory (that is, the directory that the process starts from), just the "current" directory, not necessarily the directory where the exe file resides. After you select a file with Fileopendialog, the directory changes.???
3. application.executablepath--gets the path to the executable file that launched the application, including the name of the executable file.
4. system.appdomain.currentdomain.basedirectory--gets the base directory, which is used by the Assembly resolver to probe assemblies. (used in Windows services)
Ref:http://www.cnblogs.com/guohu/archive/2012/10/20/2732199.html
20141111-WCF getting the Web path