我有listBox1并且listBox2其中加载了目录中的一些文件。最初,当我加载表单时,我禁用了listBox1和的按钮listBox2。
当目录中没有文件时,我想禁用 button1  listBox1和 button2 listBox2。
但是我想启用buttons相应的listBox1,listBox2如果目录中有单个文件并且文件是否有任何更改。
我如何使用  FileSystemWatcher??? 我需要一些想法来执行此操作。
private void PopulateListBox(ListBox lsb, string Folder, string FileType)
{
  DirectoryInfo dinfo = new DirectoryInfo(Folder);
  FileInfo[] Files = dinfo.GetFiles(FileType);
  foreach (FileInfo file in Files)
  {
    lsb.Items.Add(file);
  }
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
  FileInfo file = (FileInfo)listBox1.SelectedItem;
  string path = file.FullName;
  DisplayFile(path);
}
private void button1_Click(object sender, EventArgs e)
{
}
private void fileSystemWatcher1_Changed(object sender, FileSystemEventArgs e)
{
}
我已经在这里初始化了一个方法,从这里我该如何进行???
public void filesystemwatcher()
{
  FileSystemWatcher watcher = new FileSystemWatcher();
  watcher.Path = @"C:\LoadFiles\";                      
}