2012-02-01 95 views
0

在开发环境IIS托管WCF访问文件

string AppPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); 
       string path = AppPath + "\\options.xml"; 

作品。

当由生产IIS7服务器托管时,我把Options.xml放在bin环境中,但上述代码生成的路径是一个asp.net temp目录。 那么在开发和生产环境中访问文件的正确技术是什么? 感谢

回答

0

这是信息使用的是支持你的服务? 如果是这样,是否有任何理由,你不能只是做一个自定义的配置类,并从您的web.config节读取它?

+0

听起来像一个优雅的解决方案。充其量,我对Web.config的使用是最基本的。我会做一些挖掘。作为利益的问题解决了即时问题与字符串path = System.IO.Path.GetDirectoryName( System.Reflection.Assembly.GetExecutingAssembly()。GetName()。CodeBase)+“\\ options.xml”; – 2012-02-02 18:22:57

0

您可以使用此:

string path = System.IO.Directory.GetCurrentDirectory();