-7
  1. I need the following for adding and removing files and folders.
  2. I need to watch for changes in files and folders.
  3. All actions must be recursively.

How to do it all on c#?

Basil
  • 205
  • 1
  • 5
  • 6
    Any effort so far? – Soner Gönül Feb 06 '14 at 20:23
  • FileSystemWatcher allows all of this? Give me simple example please – Basil Feb 06 '14 at 20:25
  • @Soner Gönül: only got this task :) – Basil Feb 06 '14 at 20:27
  • @Basil Google it. There has been no effort shown on this question, just a request for the community to write your code. I suggest researching your task, attempting it and *if* you have difficulties, post a new question containing the code and the relevant question. – Robert H Feb 06 '14 at 20:27
  • @Robert How I can delete this my question? – Basil Feb 06 '14 at 20:32
  • It's right next to share, edit and flag. – Measurity Feb 06 '14 at 20:34
  • I answered the question but I agree with @Basil you should do a quick search and try few things before asking a question. – AR5HAM Feb 06 '14 at 20:42
  • possible duplicate of [C# FileSystemWatcher, How to know file copied completely into the watch folder](http://stackoverflow.com/questions/4277991/c-sharp-filesystemwatcher-how-to-know-file-copied-completely-into-the-watch-fol) – Andrei Sfat Feb 06 '14 at 20:46

1 Answers1

2

Use

 FileSystemWatcher 
Here is a simple code example watching for created file:
public void Watcher()
{
    //Create a new FileSystemWatcher.
    FileSystemWatcher watcher = new FileSystemWatcher();

    //Set the filter to only catch TXT files.
    watcher.Filter = "*.txt";

    //Subscribe to the Created event.
    //Created Occurs when a file or directory in the specified Path is created.
    //You can change this based on what you are trying to do.
    watcher.Created += new FileSystemEventHandler(YOUR_EVENT_HANDLER);

    //Set the path to you want to monitor
    watcher.Path = @"C:\PATH\";

    //Enable the FileSystemWatcher events.
    watcher.EnableRaisingEvents = true;
}
AR5HAM
  • 1,220
  • 11
  • 19