c# - How to add list of files to clipboard for cutting -


i've found this article on code project shows how add list of files (paths) clipboard , flag moving instead of copying. method used shown in multiple articles across internet , said working, can't seem work.

i'm on windows 8.1 (64 bit). after cut few files list , try paste files somewhere in explorer, hear ding , nothing happens. copying files works though.

here's have:

stringcollection paths = new stringcollection(); foreach (fileinformation file in lbxfoundfiles.selecteditems) {     paths.add(file.fileinf.fullname); }  idataobject data = new dataobject(dataformats.filedrop, paths); memorystream memo = new memorystream(4); byte[] bytes = new byte[] { 2, 0, 0, 0 }; memo.write(bytes, 0, bytes.length); data.setdata("preferred dropeffect", memo); clipboard.setdataobject(data); 

enter image description here

you've passed dataobject constructor wrong data. in such way:

byte[] moveeffect = { 2, 0, 0, 0 }; memorystream dropeffect = new memorystream(); dropeffect.write(moveeffect, 0, moveeffect.length);  stringcollection filesttocut = new stringcollection {"d:\\test.txt"}; dataobject data = new dataobject("preferred dropeffect", dropeffect); data.setfiledroplist(filesttocut);  //or execute default constructor , uncomment line below: //data.setdata("preferred dropeffect", dropeffect);  clipboard.clear(); clipboard.setdataobject(data, true);