0

How would you go about detecting, blocking, or just in general referring to the Send File operation you can do to any file/folder on Windows. What exactly is happening when a send file happens and is there any kind of built in programmability in .NET or is it something similar to how doing a move works(It gets deleted first and then created in the new location.)

I just want to know if there is any way to detect when a Send File happens or what windows does with the file/folder when a send file is executed.

  • Wouldn't you check the handler for 'Send File' in the registry? – Gayot Fow Jul 23 '13 at 18:38
  • 2
    "It gets deleted first and then created in the new location". I ***really*** hope any move routine doesn't do this. What happens in a power cut? – spender Jul 23 '13 at 18:39
  • I tried answering your question basically.. but I think you need to be much more specific about what you are trying to accomplish for a real answer – Alan Jul 23 '13 at 18:43
  • you are speaking of the menu that comes up when you right click on a file/folder in explorer? – BlackICE Jul 23 '13 at 18:47
  • So I guess to simply put what I am attempting to accomplish: I am trying to block the Send To a path/folder etc –  Jul 23 '13 at 20:24

2 Answers2

0

If you are speaking of the "Send To" context menu when you right-click on a file/folder, that is the result of a shell extension handler. Pretty sure there's now way to intercept those: Is there a Click Handler for Shell Extension

MS documentation on registering/creating your own handers is below:

http://msdn.microsoft.com/en-us/library/windows/desktop/cc144067%28v=vs.85%29.aspx

http://msdn.microsoft.com/en-us/library/windows/desktop/cc144110%28v=vs.85%29.aspx

I presume that if you select "Send To" and pick a folder/drive, then it would do a standard move or copy (depending on if it is the same drive or not). As mentioned by Alan, you can use a FileSystemWatcher to try and monitor specific files/directories, but be careful being over broad with what you are watching, because there are limitations on how fast FSW can receive events, meaning if you watch to much you will miss events. Another option if you absolutely must see the file move would be to hook into the Change Journal, but that gets really ugly.

Community
  • 1
  • 1
BlackICE
  • 8,816
  • 3
  • 53
  • 91
  • Does that mean I have no way to deal with it? How would one go about blocking Send To's to a removable device or part of the drive? –  Jul 23 '13 at 18:56
  • @JBeck are you only wanting to block the Send To, or are you blocking them from using all methods of copying to said locations? – BlackICE Jul 23 '13 at 18:58
  • I want to block the Send To –  Jul 23 '13 at 19:11
  • I don't think it's going to be possible to just block the send to. If you could block all access you could use ACL's to do it. – BlackICE Jul 24 '13 at 11:12
-1

If you want to stop someone from moving or copying a file, you would have to alter its permissions for read and/or modify to exclude the user.

There is a FileSystemWatcher class that may help you detect changes to the file system. Also, the File Class has a static method for Move and other file operations. You may look into the System.IO namespace

When you move a file, it doesn't usually get recreated and deleted (if they are on the same device). Usually its location is just modified. (hence it happens almost instantly even on large files)

Alan
  • 7,875
  • 1
  • 28
  • 48
  • ...only if they share the same drive. – spender Jul 23 '13 at 18:40
  • @spender That is why I said "usually" but I should probably update that to clarify – Alan Jul 23 '13 at 18:41
  • I am aware of the FileSystemWatcher class, and I am not concerned with moves right now or any of the other subscribed event-handlers available to FileSystemWatcher. I am concerned with how to handle a Send To within the context menu of any file/folder. –  Jul 23 '13 at 18:55