我有一个ASP.NET MVC 4应用程序。HttpContext.Current null在FileSystemWatcher内
另外我有一个XML文件位于我的应用程序的根目录。
无论何时管理员更改此文件,我都希望应用程序了解它并阅读新值。
...
FileSystemWatcher Watcher = new FileSystemWatcher();
Watcher.Changed += new FileSystemEventHandler(OnChanged);
...
private void OnChanged(object source, FileSystemEventArgs e) {
var path = HttpContext.Current.Server.MapPath("~/"))
}
每次HttpContext.Current
似乎都是空的。如何获取我的应用程序的根文件夹,如果这不起作用?