I am getting an exception in the following code:
(System.IO.MemoryStream) Stream stream = new MemoryStream(fcr.FileContents);
System.Drawing.Image img = System.Drawing.Image.FromStream(stream);
I wrapped it in a Try/Catch & the exception is thrown on the second line: Message = "Parameter is not valid."
I checked the contents of the variable stream
. This is where the error is. Expanding the contents of stream
, I find:
Read.TimeOut: 'stream.Read.TimeOut'threw an exception of type
'System.InvalidOperationException'
Write.TimeOut: 'stream.Write.TimeOut' thew an exception of type
'System.InvalidOperationException'
I have 2 questions:
How do I solve it?
using (Stream stream = new MemoryStream(fcr.FileContents))
{
System.Drawing.Image img = System.Drawing.Image.FromStream(stream, true, true);
Continues to crash in here with Parameter is not valid. The object stream still has read & write TimeOut messages.
You need to change the position before using it.
using (Stream stream = new MemoryStream(fcr.FileContents))
{
stream.Position = 0;
System.Drawing.Image img = System.Drawing.Image.FromStream(stream, true, true);
}
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