文件监听

文件监听
强烈推介IDEA2021.1.3破解激活,IntelliJ IDEA 注册码,2021.1.3IDEA 激活码  

大家好,我是架构君,一个会写代码吟诗的架构师。今天说一说文件监听,希望能够帮助大家进步!!!

private void button1_Click_1(object sender, System.EventArgs e)
{

if(this.folderBrowserDialog1.ShowDialog()==DialogResult.OK)
{

if(this.folderBrowserDialog1.SelectedPath.Trim()!="")
{

this.textBox1.Text=this.folderBrowserDialog1.SelectedPath.Trim();
}
}
}

private void button2_Click(object sender, System.EventArgs e)
{

if(!System.IO.Directory.Exists(this.textBox1.Text))
{

MessageBox.Show("",MessageBoxButtons.OK,MessageBoxIcon.Information);
return;
}
this.fileSystemWatcher1.Path=this.textBox1.Text;
MessageBox.Show(this.textBox1.Text+"",MessageBoxButtons.OK,MessageBoxIcon.Information);

}

private void fileSystemWatcher1_Changed(object sender, System.IO.FileSystemEventArgs e)
{//
this.richTextBox1.Text+=e.FullPath.ToString()+"\n";
}

private void fileSystemWatcher1_Created(object sender, System.IO.FileSystemEventArgs e)
{//
this.richTextBox1.Text+="\"+e.FullPath.ToString();
}

private void fileSystemWatcher1_Deleted(object sender, System.IO.FileSystemEventArgs e)
{//
this.richTextBox1.Text+="\n"+e.FullPath.ToString();
}

private void fileSystemWatcher1_Renamed(object sender, System.IO.RenamedEventArgs e)
{//
this.richTextBox1.Text+="\n"+e.FullPath.ToString();
}

转载于:https://www.cnblogs.com/ouyangkai/p/10937981.html

本文来源weixin_30595035,由架构君转载发布,观点不代表Java架构师必看的立场,转载请标明来源出处:https://javajgs.com/archives/29790

发表评论