Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
C# / VB.NET - c# System.InvalidOperationException non č stata gestita
Forum - C# / VB.NET - c# System.InvalidOperationException non č stata gestita

Avatar
fosforo (Normal User)
Expert


Messaggi: 391
Iscritto: 06/04/2009

Segnala al moderatore
Postato alle 15:34
Mercoledė, 27/05/2015
Questo topic č stato chiuso dal moderatore

Ciao
Ho trovato questo codice nel sito Microsoft per monitorare una cartella:

private void watch()
        {
            FileSystemWatcher watcher = new FileSystemWatcher();
            watcher.Path = FilePath;
            watcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite
                                   | NotifyFilters.FileName | NotifyFilters.DirectoryName;
            watcher.Filter = "*.*";
            watcher.Changed += new FileSystemEventHandler(OnChanged);
            watcher.Created += new FileSystemEventHandler(OnChanged);
            watcher.EnableRaisingEvents = true;
        }

private void OnChanged(object source, FileSystemEventArgs e)
        {
            textBox4 .Text = (e.FullPath );
        }

Quando metto nella cartella un file mi va in errore:
System.InvalidOperationException non č stata gestita

Grazie anticipatamente.

PM
Avatar
fosforo (Normal User)
Expert


Messaggi: 391
Iscritto: 06/04/2009

Segnala al moderatore
Postato alle 11:43
Giovedė, 28/05/2015
Risolto con:

this.textBox.Invoke(new MethodInvoker(() => this.textBox4.Text ="stringa"));

PM