Save MetaFile to Stream and back again

拥有回忆 提交于 2019-12-24 18:16:52

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!