System.IO.File.WriteAllBytes() fails on large byte arrays - by bes7252

Status : 

  Fixed<br /><br />
		This item has been fixed in the current or upcoming version of this product.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 486256 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 8/28/2009 9:06:29 AM
Access Restriction Public


System.File.IO.WriteAllBytes() fails when writing a large byte array to a network drive.  Original file is about 80 MB.  Small files work ok.  Not sure at what size they start to fail.
I've tried writing to UNC paths on 2003, 2008 and Samba.  Also tried a mapped drive (e.g F:\temp\File.pdf).  All fail.  There are no quotas in place and permissions are okay.

System.IO.File.Copy() and System.IO.File.Move() both work on the same file without error.
Sign in to post a comment.
Posted by bes7252 on 10/5/2009 at 2:38 PM

The status of this ticket just changed to fixed. Updating the documentation doesn't really fix the problem...I still cannot write a 66MB file to a network drive.

Will the underlying Win32 library ever be modified? How about the x64 library?

Posted by Microsoft on 9/17/2009 at 1:29 PM
Hello bes7252,
Sorry for the issue with WriteAllBytes() throwing IOException when writing large files (64MB+) to network paths. The underlying Win32 WriteFile API limits network write operations to 65,535 bytes per write. In order to write large files over the network, the writes will have to be done in multiple chunks, each under 64MB.

I will make sure the System.IO documentation is updated on to reflect this size limitation when working with network paths.

Thank you,
Josh Free
Base Class Library Development
Posted by bes7252 on 8/31/2009 at 6:15 AM
Will the status of this ticket be updated if it's fixed?
Posted by Microsoft on 8/31/2009 at 12:20 AM
Thanks for your feedback. We are routing this bug to the product unit who works on that specific feature area. The team will review this issue and make a decision on whether they will fix it or not for the next release.

Thank you,
Visual Studio Product Team