Link to home
Start Free TrialLog in
Avatar of zimmer9
zimmer9Flag for United States of America

asked on

C# application error "Parameter Is Not Valid".

I am working on a C# application that merges the front and back of check images that are contained in 1 input file.
I have attached my application and a sample input file that is comprised of the front and back of 2 checks.

Do you know why I get the error:

Exception reported: System.ArgumentException: Parameter is not valid.
  at System.Drawing.Image.Save(Stream stream, ImageCodecInfo encoder, EncoderParameters encoderParams)
  at System.Drawing.Image.Save(Stream stream, ImageFormat format)
  at ReadBinary.Extensions.MergeImages(IEnumerable`1 images, FileInfo file) in \\msad\Visual Studio 2015\Projects\Program.cs:line 87

It happens at:
line 87 ->   image.Save(stream, ImageFormat.Tiff);

In the application I can successfully create the front and back of check images successfully as individual files using the following code but I can't merge the front and back of check images successfully and write the merged check images to a file:

MemoryStream ms = new MemoryStream(bytesFrImg, 0, bytesFrImg.Length);
                                                    ms.Write(bytesFrImg, 0, bytesFrImg.Length);
                                                    System.Drawing.Image image = System.Drawing.Image.FromStream(ms, true);
                                                    image.Save("L:\\FINSYS\\FSMain\\C\\Source\\" + DateTime.Now.ToString("yyyyMMdd.HHmmss") +

MyGlobals.ctnumImg + "F.ard.out");            //, System.Drawing.Imaging.ImageFormat);

                                                    MemoryStream ms1 = new MemoryStream(bytesBkImg, 0, bytesBkImg.Length);
                                                    ms1.Write(bytesBkImg, 0, bytesBkImg.Length);
                                                    System.Drawing.Image image1 = System.Drawing.Image.FromStream(ms1, true);
                                                    image1.Save("L:\\FINSYS\\FSMain\\C\\Source\\" + DateTime.Now.ToString("yyyyMMdd.HHmmss") +
CheckImage.txt
sample.txt
ASKER CERTIFIED SOLUTION
Avatar of zephyr_hex (Megan)
zephyr_hex (Megan)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Robberbaron (robr)
Robberbaron (robr)
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial