Search code examples
c#pinvokewindows-explorerfile-transfer

C#: take control over file transfers*


I'd like to have a program that runs in the background, listens for any file transfers, and then cancels explorer's file transfer mechanism, and starts it's own.

How do I do this? Is there some dll that I can pinvoke?

Why?

  • To filter files of certain types along the way. (automatically, or with a prompt.)
  • A "no to all" duplicate transfers option.
  • Logging.
  • To not have to start the program up every time I want to transfer files.
  • To further understand what's going on under the hood.
  • To not rely on third party programs.
  • Any additional features I think of in the future.

* By file transfers I mean moving/copying files/folders via drag and drop, but I am only concerned with file transfers from disk to disk, not from the internet.


Solution

  • Define "file transfer".

    Do you want to sniff for ftp, http requests? Explorer copies as well? Local only or on the network?

    I think this is bound to get brittle. Your best bet would be if explorer let's you hook into file copy operations via a shell extension. I'm not sure whether it can be done.

    See The Complete Idiot's Guide to Writing Shell Extensions for a starting point.

    See also http://msdn.microsoft.com/en-us/library/cc144063(v=vs.85).aspx