views:

377

answers:

1

Hi, I'm looking for a way to programmatically cut a file to the clipboard, e. g. some call to a function in C# that does the same as selecting a file in the Windows Explorer and pressing Ctrl+X So after running the program and pressing Ctrl+V in some other folder on the hard drive, the original file would be MOVED to the new folder. By looking at this question http://stackoverflow.com/questions/211611/copy-files-to-clipboard-in-c I know that it's easy to do the copy job but cutting seems to work different. Thanks for your help.

+3  A: 

Please try the following, translated from here:

byte[] moveEffect = new byte[] {2, 0, 0, 0};
MemoryStream dropEffect = new MemoryStream();
dropEffect.Write(moveEffect, 0, moveEffect.Length);

DataObject data = new DataObject();
data.SetFileDropList(files);
data.SetData("Preferred DropEffect", dropEffect);

Clipboard.Clear();
Clipboard.SetDataObject(data, true);
Dark Falcon
"Clipboard.SetDataObject(data_object, True);" : where does the variable "data_object" come from here : is this, by chance, meant to be "data" ?
BillW
Yes, I did mean "data".
Dark Falcon
Works perfectly, thank you! :)
friederbluemle