private void button1_Click(object sender, System.EventArgs e)
{
FileSystemWatcher mywatch= new FileSystemWatcher(); mywatch.Path="f:\\";
//the file that is watched is what type
mywatch.Filter="*.doc";
//add event
mywatch.Renamed+=new RenamedEventHandler(this.rename_do);
mywatch.Changed+=new FileSystemEventHandler(this.change_do);
//start watch
mywatch.EnableRaisingEvents=true;
}
private void rename_do(object sender, System.IO.RenamedEventArgs e)
{
MessageBox.Show(e.OldName .ToString()+" 已改变! ","rename提示");
MessageBox.Show(e.FullPath.ToString()+" 已改变! ","rename提示");
MessageBox.Show(e.Name.ToString()+" 已改变! ","rename提示");
} private void change_do(object sender, System.IO.FileSystemEventArgs e)
{
string s=e.Name.ToString();
s=s.Replace("~$","");
if(s=="1.doc")
MessageBox.Show(e.FullPath.ToString()+" 已改变! ","chang提示");
}
{
FileSystemWatcher mywatch= new FileSystemWatcher(); mywatch.Path="f:\\";
//the file that is watched is what type
mywatch.Filter="*.doc";
//add event
mywatch.Renamed+=new RenamedEventHandler(this.rename_do);
mywatch.Changed+=new FileSystemEventHandler(this.change_do);
//start watch
mywatch.EnableRaisingEvents=true;
}
private void rename_do(object sender, System.IO.RenamedEventArgs e)
{
MessageBox.Show(e.OldName .ToString()+" 已改变! ","rename提示");
MessageBox.Show(e.FullPath.ToString()+" 已改变! ","rename提示");
MessageBox.Show(e.Name.ToString()+" 已改变! ","rename提示");
} private void change_do(object sender, System.IO.FileSystemEventArgs e)
{
string s=e.Name.ToString();
s=s.Replace("~$","");
if(s=="1.doc")
MessageBox.Show(e.FullPath.ToString()+" 已改变! ","chang提示");
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货