FileSystemWatcher filter problem and how it works
-
FSW dont raise event when i set its filter to custom extension, like if i set it to "*.abcd" then no event will raise but if i set it to other known extensions like "*.txt" or something else it works, any idea how to solve ? my second question is that how it works, is it works like timer mean it keep refresh after some inbuilt specified time or any window function send info to it when a file created and it raises event ? thanks
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L %^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2 W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN% Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia> -------------------------------------------------------- 128 bit encrypted signature, crack if you can
-
FSW dont raise event when i set its filter to custom extension, like if i set it to "*.abcd" then no event will raise but if i set it to other known extensions like "*.txt" or something else it works, any idea how to solve ? my second question is that how it works, is it works like timer mean it keep refresh after some inbuilt specified time or any window function send info to it when a file created and it raises event ? thanks
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L %^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2 W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN% Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia> -------------------------------------------------------- 128 bit encrypted signature, crack if you can
FSW monitors a directory for file creation, modification, deletion and renaming. The custom expression is to monitor only those file types that match that expression. This example monitors only the directory where dir == the directory to monitor and only raise an event on file types of txt.
fileWatcher = new FileSystemWatcher(dir, "*.txt");
fileWatcher.EnableRaisingEvents = false;
fileWatcher.IncludeSubdirectories = false;
fileWatcher.NotifyFilter = NotifyFilters.FileName;
fileWatcher.Created += new FileSystemEventHandler(fileWatcher_Created);Set fileWatcher.EnableRaisingEvents = true to enable the monitoring. To stop monitoring set the value to false. http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.aspx[^]
Just because we can; does not mean we should.
-
FSW monitors a directory for file creation, modification, deletion and renaming. The custom expression is to monitor only those file types that match that expression. This example monitors only the directory where dir == the directory to monitor and only raise an event on file types of txt.
fileWatcher = new FileSystemWatcher(dir, "*.txt");
fileWatcher.EnableRaisingEvents = false;
fileWatcher.IncludeSubdirectories = false;
fileWatcher.NotifyFilter = NotifyFilters.FileName;
fileWatcher.Created += new FileSystemEventHandler(fileWatcher_Created);Set fileWatcher.EnableRaisingEvents = true to enable the monitoring. To stop monitoring set the value to false. http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.aspx[^]
Just because we can; does not mean we should.
i know that, i think you didnt read my problem properly :) i said it dont raise any event when i set custom filter, for example if i write FSW.Filter = "*.abcd"; // wont work, if i create any file with extension abcd but if i write FSW.Filter = **.txt"; // will work, if i create any file with extension txt EDITED : SOLVED
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L %^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2 W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN% Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia> -------------------------------------------------------- 128 bit encrypted signature, crack if you can
-
i know that, i think you didnt read my problem properly :) i said it dont raise any event when i set custom filter, for example if i write FSW.Filter = "*.abcd"; // wont work, if i create any file with extension abcd but if i write FSW.Filter = **.txt"; // will work, if i create any file with extension txt EDITED : SOLVED
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L %^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2 W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN% Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia> -------------------------------------------------------- 128 bit encrypted signature, crack if you can
Not sure where your having problems. I did this test and had no problems getting the notifications. Sorry
private void Form1\_Load(object sender, EventArgs e) { fileSystemWatcher1 = new System.IO.FileSystemWatcher(@"C:\\"); fileSystemWatcher1.IncludeSubdirectories = false; fileSystemWatcher1.NotifyFilter = NotifyFilters.FileName; fileSystemWatcher1.Filter = "\*.abcd"; fileSystemWatcher1.Created += new System.IO.FileSystemEventHandler(fileSystemWatcher1\_Created); fileSystemWatcher1.Changed += new System.IO.FileSystemEventHandler(fileSystemWatcher1\_Changed); fileSystemWatcher1.Renamed += new RenamedEventHandler(fileSystemWatcher1\_Renamed); fileSystemWatcher1.Deleted += new FileSystemEventHandler(fileSystemWatcher1\_Deleted); fileSystemWatcher1.EnableRaisingEvents = true; File.Delete(@"C:\\test.abcd"); StreamWriter sw = new StreamWriter(@"C:\\test.abcd",true); sw.WriteLine("test"); sw.Close(); sw.Dispose(); } void fileSystemWatcher1\_Deleted(object sender, FileSystemEventArgs e) { MessageBox.Show("File Deleted " + e.FullPath.ToString()); } void fileSystemWatcher1\_Renamed(object sender, RenamedEventArgs e) { MessageBox.Show("File Renamed " + e.FullPath.ToString()); } void fileSystemWatcher1\_Changed(object sender, System.IO.FileSystemEventArgs e) { MessageBox.Show("File Changed " + e.FullPath.ToString()); } void fileSystemWatcher1\_Created(object sender, System.IO.FileSystemEventArgs e) { MessageBox.Show("File Created " + e.FullPath.ToString()); }
Just because we can; does not mean we should.
-
Not sure where your having problems. I did this test and had no problems getting the notifications. Sorry
private void Form1\_Load(object sender, EventArgs e) { fileSystemWatcher1 = new System.IO.FileSystemWatcher(@"C:\\"); fileSystemWatcher1.IncludeSubdirectories = false; fileSystemWatcher1.NotifyFilter = NotifyFilters.FileName; fileSystemWatcher1.Filter = "\*.abcd"; fileSystemWatcher1.Created += new System.IO.FileSystemEventHandler(fileSystemWatcher1\_Created); fileSystemWatcher1.Changed += new System.IO.FileSystemEventHandler(fileSystemWatcher1\_Changed); fileSystemWatcher1.Renamed += new RenamedEventHandler(fileSystemWatcher1\_Renamed); fileSystemWatcher1.Deleted += new FileSystemEventHandler(fileSystemWatcher1\_Deleted); fileSystemWatcher1.EnableRaisingEvents = true; File.Delete(@"C:\\test.abcd"); StreamWriter sw = new StreamWriter(@"C:\\test.abcd",true); sw.WriteLine("test"); sw.Close(); sw.Dispose(); } void fileSystemWatcher1\_Deleted(object sender, FileSystemEventArgs e) { MessageBox.Show("File Deleted " + e.FullPath.ToString()); } void fileSystemWatcher1\_Renamed(object sender, RenamedEventArgs e) { MessageBox.Show("File Renamed " + e.FullPath.ToString()); } void fileSystemWatcher1\_Changed(object sender, System.IO.FileSystemEventArgs e) { MessageBox.Show("File Changed " + e.FullPath.ToString()); } void fileSystemWatcher1\_Created(object sender, System.IO.FileSystemEventArgs e) { MessageBox.Show("File Created " + e.FullPath.ToString()); }
Just because we can; does not mean we should.
thanks for reply but as i said in previous post that problem solved because i had an error in that extension :) :)
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L %^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2 W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN% Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia> -------------------------------------------------------- 128 bit encrypted signature, crack if you can