Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
System.IO.FileSystemWatcher issue
Message
De
18/06/2004 10:44:30
Keith Payne
Technical Marketing Solutions
Floride, États-Unis
 
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00914845
Message ID:
00915052
Vues:
14
>Oh yea, details... <g> I ought to know better. It's a WinForms app. This code is in the constructor after the InitializeComponents() line:
>
>try
>{
> System.IO.FileSystemWatcher watcher = new System.IO.FileSystemWatcher();
> watcher.Path = this.txtWatchForStartFile.Text.Trim();
> watcher.Filter = "start.txt";
> watcher.Created += new System.IO.FileSystemEventHandler(OnStartFileAppeared);
> watcher.EnableRaisingEvents = true;
>}
>catch (Exception err)
>{
> MessageBox.Show(err.Message + "\n\nStack: " + err.StackTrace,
> "Can Not Watch for start.txt file - Use GO NOW button");
>}
>
>And the method code...
>public void OnStartFileAppeared(object source, System.IO.FileSystemEventArgs e)
>{
> this.btnGO_Click(source, e);
>}

Mike,

Well, the code looks fine. I was thinking that there might be some static methods in there somewhere, but this is not the case. I did some research on the FileSystemWatcher, and it seems that the general concensus is that it is only as reliable as the operating system that initially fires the events.

Perhaps the answer is to create one windows service that watches the directory. You could use MSMQ to notify the application, or hook the application's events to the windows service.

I'm sorry that I haven't been more helpful.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform