我有一个包含PNG文件的资源文件我希望将字节数组写入End Of File
PNG图像但是当从流中保存文件时删除字节数组,我想将隐藏的字节写入PNG文件,如何解决这个问题?
谢谢你提前。
public void Method()
{
using (var reader = new ResourceReader("My.resource"))
{
var iter = reader.GetEnumerator();
var ms = new MemoryStream();
var writer = new System.Resources.ResourceWriter(ms);
while (iter.MoveNext())
{
var key = iter.Key as string;
var value = iter.Value as Bitmap;
MemoryStream stream = new MemoryStream();
value.Save(stream, value.RawFormat);
byte[] b = new byte[] {0x11, 0x22, 0x33};
stream.Write(b, 0, b.Length);
Image bitmap = Image.FromStream(stream);
writer.AddResource(key, bitmap);
}
writer.Generate();
File.WriteAllBytes("My1.resource", ms.ToArray());
}
}