我没有设法在新的 FileSystemWatcher 事件上使用 Response.Redirect(或 Response.Write)。
protected void Page_Load(object sender, EventArgs e)
{
RunFolderListener();
}
private void RunFolderListener()
{
FileSystemWatcher fsw = new FileSystemWatcher();
fsw.Path = Server.MapPath("~/uploaded_images/");
fsw.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite |
NotifyFilters.DirectoryName | NotifyFilters.FileName;
fsw.Changed += new FileSystemEventHandler(OnChanged);
fsw.EnableRaisingEvents = true;
}
private void OnChanged(object source, FileSystemEventArgs e)
{
Response.Redirect(....); //not working
Response.Write (....);//not working
}