问题
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?
来源:https://stackoverflow.com/questions/22426019/save-metafile-to-stream-and-back-again