I have a standard SOAP webservice with a WebMethod which accepts a byte array and then performs a
[WebMethod(true)]
WriteFile(byte[] Data, string FilePath)
{
File.WriteAllBytes(FilePath, Data);
}
If this process is passed a large file, e.g. 2 meg it is bombing out with the following error message:
Insufficient system resources exist to complete the requested service
Looking at the stack trace i'm getting:
I've tried all the obvious things such as setting the maxrequestlength and executing timeout to more realistic settings:
<httpRuntime maxRequestLength="409600" executionTimeout="900"/>
It still seems to fail over with the above. If you send a smaller file it saves to disk fine.. So it's either file size or time that's the issue.
Does anyone know of anything else i can do to sort this out?
Thanks
Dave
I know you are not reaching this size of file but also be aware that File.WriteAllBytes has a limit of 64mb when writing to network paths - see this connect issue
I was receiving a similar error message when using File.WriteAllBytes and changed my code to use a FileStream as in the example below. Based on the comments of others, my guess is that FileStream has a smaller memory impact.
using (FileStream stream = new FileStream(FilePath, FileMode.Create, FileAccess.ReadWrite))
{
stream.Write(Data, 0, Data.Length);
stream.Close();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With