c# - copy large 'ref byte' chunks to file -
i'm struggling in head what's best way of copying large data comes dll ref byte file.
since it's video stream (or hundreds) don't feel comfortable using marhal.copy/ writebyte in loop, , etc.. more direct.
i'm pretty stucked ref byte , unfortunately don't have it.
anyways, thinking p/invoke writefile gets intptr closest ref byte of course byte* (using fixed).
now, i'm going have few hundreds of kind of stream, , each 1 can ~2mbps.
@ bottom line - i'm searching efficient way of copying ref byte chunks file (with given array size of course).
well in case interested, , mr. smith, first changed given dllimport ref byte declarations intptr.
imported writefile:
[dllimport("kernel32.dll")] private static extern bool writefile(intptr hfile, intptr lpbuffer, int numberofbytestowrite, out int lpnumberofbyteswritten, intptr lpoverlapped); and used follows:
//somewhere in class: tmpfilestream = new filestream("tmp.bin", filemode.create, fileaccess.write); public void addbuffer(intptr buffer, int size) { int written; writefile(tmpfilestream.safefilehandle.dangerousgethandle(), buffer, size, out written, intptr.zero); }
Comments
Post a Comment