1

I need to store a MetaFile into a Stream and create a new Metafile with the same stream.

I have the following code but it throws an excetpion:

string tempPath = Path.GetTempFileName();
MyMetaFile.Save(tempPath);
var stream = new MemoryStream(File.ReadAllBytes(tempPath));
File.Delete(tempPath);
var newMetafile = new Metafile(stream);  // here the exception

The exception message says: ExternalException: A generic error occured in GDI+.

I tried also to use the method Image.Save(stream, ImageFormat.Emf) but it throws an exception too.

How can I fix this problem?

Nick
  • 10,309
  • 21
  • 97
  • 201
  • I have recently worked out how to write metafiles to disk. Perhaps it will help: http://stackoverflow.com/questions/25560157/how-to-write-an-old-style-metafile-to-a-file [1]: http://stackoverflow.com/questions/25560157/how-to-write-an-old-style-metafile-to-a-file/25560158#25560158 – Oliver Bock Aug 29 '14 at 00:57

0 Answers0