質問

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