문제

I'm creating a simple program that manages some files and that program must keep track of file movements made by user.

(I'm not worried at this point about catching all running Windos Explorer's windows and about keeping the program always activated in the tray bar, but I might ask that later in another question)

So, what I need is simply:

  • Launch Windows Explorer Programatically
  • Monitor all file movements, creations and exclusions (made by user inside that window)

Is there an API to use with C#?

P.S: It's a Winforms application, so if there are other ways of doing this, they would be appreciated as well.

Thank you.

올바른 솔루션이 없습니다

다른 팁

You can use the FileSystemWatcher

To initialize the FileSystemWatcher:

FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(@"E:\TestDir");
fileSystemWatcher.Changed += OnChanged;
fileSystemWatcher.Created += OnChanged;
fileSystemWatcher.Deleted += OnChanged;
fileSystemWatcher.Renamed += OnChanged;
fileSystemWatcher.EnableRaisingEvents = true;

And the OnChanged-Event:

private static void OnChanged(object sender, FileSystemEventArgs e)
    {
        WatcherChangeTypes watcherChangeTypes = e.ChangeType;
        string fullPath = e.FullPath;
        string name = e.Name;
    }
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top