Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

C# Write File larger than 64 MB to network (UNC)

Avatar of ppittle
ppittleFlag for United States of America asked on
C#Windows Server 2003ASP.NET
7 Comments1 Solution2796 ViewsLast Modified:
I have a basic File Upload web site that allows users to upload files.  The files are then written out to two separate servers.  I've been using code similar to this:

byte[] byteArrayContainingUploadedFileBinary;

File.WriteAllBytes("\\server1\FileShare\", byteArrayContainingUploadedFileBinary);
File.WriteAllBytes("\\server2\FileShare\", byteArrayContainingUploadedFileBinary);

This works fine if the user uploads a file less than 64 MB.  If the file is larger than 64 MB I receive an IOException.  Microsoft indicates this is "by design", as this error is described in the method documentation.  http://msdn.microsoft.com/en-us/library/system.io.file.writeallbytes.aspx

I also tried using FileStream, but that doesn't work.  Interestingly enough, File.WriteAllBytes uses a FileStream internally.  Even though the msdn documentation for FileStream doesn't explicitly state the same 64 MB limit when writing to a UNC location, the FileStream class still fails with files over 64mb.

Does anyone know of a good way to write a file larger than 64MB to a UNC location?

Thanks,

PJ

Sorry about the low points for this question.  I only have 120 left.
ASKER CERTIFIED SOLUTION
Avatar of algen
algenFlag of United States of America image

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Commented:
This problem has been solved!
Unlock 1 Answer and 7 Comments.
See Answers