私のasp.netアプリケーションでは、utilクラスがxmlファイルからいくつかのデータを読み取り、後でこのクラスを呼び出すことができます。ファイルは一度ロードする必要があるため、静的コンストラクターを使用します。
class UtilHelper{
static UtilHelper(){
XmlDocument doc=new XmlDocument();
doc.load("a.xml"); //here the asp.net cannot find the file,it always try to find file in the iis's dictionary.
}
}
「Server.mappath(xxx)」の使用を提案する人もいるかもしれません
ただし、このクラスはxx.aspx.csではありません。したがって、コンテキストには「HttpRequest」または「HttpServerUtilly」はありません。
何か案は?