private void NewItem(object source, FileSystemEventArgs e)
 {
     whatHappened = e.Name + " was created";
     DirectoryInfo s = new DirectoryInfo(address);
     FileInfo[] items = s.GetFiles("*." + ending);
     Files.Clear();
     for (int i = 0; i < items.Count(); i++)
     {
         FileToMonitor newFile = new FileToMonitor(items[i].Name, address);
         Files.Add(newFile);
     }
 }
Esempio n. 2
0
        private void RenamedItem(object source, RenamedEventArgs e)
        {
            whatHappened = e.OldName + " was renamed to " + e.Name;
            DirectoryInfo s = new DirectoryInfo(address);

            FileInfo[] items = s.GetFiles("*." + ending);
            Files.Clear();
            for (int i = 0; i < items.Count(); i++)
            {
                FileToMonitor newFile = new FileToMonitor(items[i].Name, address);
                Files.Add(newFile);
            }
        }
Esempio n. 3
0
        private void NewItem(object source, FileSystemEventArgs e)
        {
            whatHappened = e.Name + " was created";
            DirectoryInfo s = new DirectoryInfo(address);

            FileInfo[] items = s.GetFiles("*." + ending);
            Files.Clear();
            for (int i = 0; i < items.Count(); i++)
            {
                FileToMonitor newFile = new FileToMonitor(items[i].Name, address);
                Files.Add(newFile);
            }
        }
Esempio n. 4
0
 private void StartWatch()
 {
     if (ending != "")
     {
         watcher = new FileSystemWatcher(address, "*." + ending);
         DirectoryInfo s     = new DirectoryInfo(address);
         FileInfo[]    items = s.GetFiles("*." + ending);
         Files.Clear();
         for (int i = 0; i < items.Count(); i++)
         {
             FileToMonitor newFile = new FileToMonitor(items[i].Name, address);
             Files.Add(newFile);
         }
         watcher.Created            += new FileSystemEventHandler(NewItem);
         watcher.Deleted            += new FileSystemEventHandler(DeletedItem);
         watcher.Renamed            += new RenamedEventHandler(RenamedItem);
         watcher.EnableRaisingEvents = true;
     }
 }
 private void StartWatch()
 {
     if (ending != "")
     {
         watcher = new FileSystemWatcher(address, "*." + ending);
         DirectoryInfo s = new DirectoryInfo(address);
         FileInfo[] items = s.GetFiles("*." + ending);
         Files.Clear();
         for (int i = 0; i < items.Count(); i++)
         {
             FileToMonitor newFile = new FileToMonitor(items[i].Name, address);
             Files.Add(newFile);
         }
         watcher.Created += new FileSystemEventHandler(NewItem);
         watcher.Deleted += new FileSystemEventHandler(DeletedItem);
         watcher.Renamed += new RenamedEventHandler(RenamedItem);
         watcher.EnableRaisingEvents = true;
     }
 }
 private void RenamedItem(object source, RenamedEventArgs e)
 {
     whatHappened =e.OldName + " was renamed to " + e.Name;
     DirectoryInfo s = new DirectoryInfo(address);
     FileInfo[] items = s.GetFiles("*." + ending);
     Files.Clear();
     for (int i = 0; i < items.Count(); i++)
     {
         FileToMonitor newFile = new FileToMonitor(items[i].Name, address);
         Files.Add(newFile);
     }
 }