Reputation: 238
I am using the following code to get a byte array out of an HttPostedFileBase object
byte[] mobileAppByteArray = default(byte[]);
using (MemoryStream ms = new MemoryStream())
{
httpPostedFileObject.InputStream.CopyTo(ms);
mobileAppByteArray = ms.GetBuffer();
}
The original size of the httpPostedFileObject is 3191KB, but after the above conversion and saving it to disk, the file size is 4096KB
I understand that the default buffer size for CopyTo
is 4096, but even if I change the buffer size to 1024, the result is the same: file size is 4096KB.
How can I change my code so that my file remains as 3191KB after I save to disk?
Upvotes: 3
Views: 1064