1
나는 어떤 파일 시스템 감시자가 어떤 일을하는지 감시하기위한 모니터링 페이지를 만들고있다.다중리스트 박스 컨트롤을 가진 다중 FileSystem 감시자
private void WatchFile(TextBox ctrlTB,ListBox ctrlLB,FileSystemWatcher _watcher)
{
// FileSystemWatcher _watcher = new FileSystemWatcher();
//var localTB = ctrlTB as TextBox;
//var localLB = ctrlLB as ListBox;
_watcher.Path = ctrlTB.Text;
_watcher.Path = ctrlTB.Text;
_watcher.NotifyFilter = NotifyFilters.LastWrite;
_watcher.Filter = "*.xml";
_watcher.Changed += new FileSystemEventHandler(convertXML);
// _watcher.Changed += (s, e) => convertXML(s,e);
// _watcher.Error += new ErrorEventHandler(WatcherError);
_watcher.EnableRaisingEvents = true;
_watcher.IncludeSubdirectories = false;
ctrlLB.Items.Add("Started Monitoring @ " + ctrlTB.Text);
ctrlLB.SelectedIndex = ctrlLB.Items.Count - 1;
}
public void convertXML(object source, FileSystemEventArgs f)
{
/// some job
}
나는 그것의 각각 다시 각은 FileSystemWatcher의 상태를 다시 게시해야합니다 내가 알 필요하면 여러 파일 시스템 감시자의이 UI 스레드에서 목록 상자에 액세스 할 수 ... 여기에 몇 가지 코드받을 수 있나요 어떻게 리스트 박스. 시작 버튼을 클릭하면 FSW가 선언됩니다. 모든 목록 상자에는 별도로 선언 할 시작 버튼이 있습니다. 예 :
private void button9_Click(object sender, EventArgs e)
{
if (!Directory.Exists(this.textBox1.Text))
{
//Form2.ActiveForm.Text = "Please select Source Folder";
// popup.Show("Please Select Source Folder");
MessageBox.Show("Please Select Proper Source Folder");
return;
}
else
{
textBox1.Enabled = false;
button9.Enabled = false;
button1.Enabled = false;
// button4.Enabled = false;
FileSystemWatcher _watcher = new FileSystemWatcher();
_watcher.SynchronizingObject = this;
WatchFile(textBox1,listBox1 ,_watcher);
}
}
스레드는 액세스 할 contrl 목록 상자를 어떻게 알 수 있습니까? 대답에 대해 많은 것을 알고 있습니다.
이 모양이 좋고 이해할 만합니다. 이걸 시험해 볼게요. 곧 연락 드리겠습니다. 고맙습니다. – user726720
+1 설명이 필요합니다. – user726720
걱정할 필요가 없습니다. 도와 줘서 기뻐. – Adrian