Torna al Thread

//[PermissionSet(SecurityAction.Demand, Name = "FullTrust")] public static void Run() { // Create a new FileSystemWatcher and set its properties. FileSystemWatcher watcher = new FileSystemWatcher(); watcher.Path = @"z:\Universita\informatica2\progetti visual c#\"; watcher.Filter = "dati.txt"; watcher.Changed += new FileSystemEventHandler(OnChanged); watcher.EnableRaisingEvents = true; } private static void OnChanged(object source, FileSystemEventArgs e) { // Se lascio solo la messagebox tutto funziona MessageBox.Show("ciao"); //Se ci metto questo viene l'errore che ho riportato sopra per ogni listbox scritta in questo pezzo di codice. StreamReader sr = File.OpenText("dati.txt"); string riga = "aa"; do { lstbox.Items.Add(riga); riga = sr.ReadLine(); } while (riga != null); lstbox.SelectedIndex = Convert.ToInt32(txtindex.Text); sr.Close(); } } }
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5