I am trying to create an EMF image from a MS Chart graph. I have got no problem using a FileStream
to temporary store the image like this:
FileStream fileStream = new FileStream("test.emf", FileMode.Create);
chart1.SaveImage(fileStream, ChartImageFormat.EmfPlus);
fileStream.Close();
Image emf = Metafile.FromFile("test.emf");
But if I try to get rid of the file using a MemoryStream
I get a System.ArgumentException
HResult=0x80070057 (invalid parameter).
MemoryStream memoryStream = new MemoryStream();
chart1.SaveImage(memoryStream, ChartImageFormat.EmfPlus);
Image emf = Metafile.FromStream(memoryStream);
I can't figure out why it is not working. I've read that the problem may be caused by the need to dispose the Graphics
object. How can do it?
User contributions licensed under CC BY-SA 3.0