Search code examples
c#clipboardfile-manager

C# Files - in clipboard How to set/read which operation is called - Cut or Copy


I have read many topics about cut/copy to clipboard, but haven't found the answer for my problem

I'm working on a "File Manager" application like Windows Explorer. Files are listed in a listview, in details view.

I have CUT/COPY/PASTE operations, and I know how to use File.Move, .Copy, Clipboard.GetFileDropList(), .SetFileDropList()........... and it works great.

What I dont know is how and where can I write in memory (which method) and how can I read from memory (Clipboard) which operation is last used, Cut or Copy? Is there any string in memory windows explorer writes, that I can read and then know if it is CUT or COPY?

I want to let the user be able to cut/copy from my app to win Explorer and vice versa.


Solution

  • If you want to determine which Clipboard operation was last called, I think you have to listen to Windows messages, particularly WM_CUT (0x0300) versus WM_COPY (0x0301), and track which was last sent/received. You can override the Control.WndProc method as discussed on MSDN.

    Here are a few more reference links for Windows messages:

    Clipboard messages

    WM_CUT

    WM_COPY