copy - Why is FileStream and CopyFile so much slower than Windows Explorer? -


i'm trying copy file across network (windows server 2008 r2 windows 7 sp1 enterprise) , when drag-and-drop using windows explorer, i'm getting 4.5 mb/s. (it's wan connection)

however, when use filestream.read(), i'm getting around 1.5 mb/s. i've tried different buffer-sizes ranging 1 kb 4 mb. i've tried using copyfile() , copyfileex() getting same results.

what might going on here , how can fix code?

edit: i've tried using teracopy (3rd party tool) , getting 1.5 mb/s.

i don't know if still experiencing issue or not, have been wrestling issue days thought post this. found solution par explorer copy routine. not know if works filestream, was able use copyfile or copyfileex same performance. in case, copyfileex better choice because wanted progress callback. after using process monitor examine copy proccess, noticed system resetting stream position (even though hadn't moved) before every single read , write operation each 32k chunk copy (hence poor performance). key in either case set io permissions on source , destination files using fileiopermission before starting copy operation.

here's relevant excerpt code:

new fileiopermission(fileiopermissionaccess.read, sourcepath).demand(); new fileiopermission(fileiopermissionaccess.write, destinationpath).demand();  if (!nativecopy.copyfileex(sourcepath, destinationpath,     new nativecopy.copyprogressroutine(this.copyprogresshandler), gchandle.tointptr(hargs),     ref pbcancel, flags)) {     throw new ioexception(new system.componentmodel.win32exception().message); } 

hopes helps. drove me crazy trying figure out going on.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -