/// <summary>
/// 设置Config监控
/// </summary>
/// <param name="sectionName"></param>
/// <param name="path"></param>
private static void SetupWacher(string path)
{
if (_watcher == null)
{
lock (_lockObj)
{
if (_watcher == null)
{
FileInfo file = new FileInfo(path);
_watcher = new FileSystemWatcher(file.DirectoryName);
_watcher.Filter = file.Name;
_watcher.NotifyFilter = NotifyFilters.LastWrite;
_watcher.EnableRaisingEvents = true;
_watcher.Changed += new FileSystemEventHandler(_watcher_Changed);
}
}
}
}
static void _watcher_Changed(object sender, FileSystemEventArgs e)
{
RestartAppDomain();
}
/// <summary>
///
/// </summary>
public static bool RestartAppDomain()
{
bool restarted = false;
try
{
HttpRuntime.UnloadAppDomain();
restarted = true;
}
catch
{
restarted = false;
}
return restarted;
}
//获取文件目录信息
Path.GetDirectoryName(SqlConfigListFilePath);