resourcelib icon indicating copy to clipboard operation
resourcelib copied to clipboard

Save GenericResource

Open codebude opened this issue 13 years ago • 3 comments

Hello,

I try to change a .png-File in a ressource. I'm really sure, that the choosen ressource is a correct png resource. I also exported the resource. All ok. But wenn I change the data with some other .png data, it crashes with an Win32 Exception. (Translated from german to english it means something like "This requirement/request is not supported.")

It crashs at the last line (saveTo()) from my example.

filename = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), "imageres.dll");

using (ResourceInfo vi = new ResourceInfo())
 {
                vi.Load(filename);

        //Take a png resource
                GenericResource res = (vi.Resources[vi.ResourceTypes[2]][14] as GenericResource);

                Image imageIn = Image.FromFile(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), "import.png"));
                MemoryStream ms = new MemoryStream();
                imageIn.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                res.Data = ms.ToArray();

        //Win32 Exception. Why?
                res.SaveTo(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), "imageres.dll"));
}

Greets, Raffael

codebude avatar Aug 28 '12 18:08 codebude

Did you ever solve this? Ca you post the entire stack please and maybe write this repro as a unit test within the project? Thx.

dblock avatar Apr 14 '13 14:04 dblock

You're trying to save a GenericResource, this looks like the same issue as #75. @dblock are there any plans to fix this?

yoshiask avatar Oct 25 '21 05:10 yoshiask

@yoshiask I don't have any plans to fix it, but you're welcome to please contribute!

dblock avatar Oct 25 '21 14:10 dblock