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
2010-01-16 16:29:34
"Clipboard.SetDataObject(data_object, True);" : where does the variable "data_object" come from here : is this, by chance, meant to be "data" ?
BillW
2010-01-16 16:42:15
Yes, I did mean "data".
Dark Falcon
2010-01-16 16:42:59
Works perfectly, thank you! :)
friederbluemle
2010-01-16 18:42:32