Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

[Solved] How to save files as new resource? Like a .Zip file or .exe not Txt files?

SOLUTION: You don't....



I want to know how to actually ADD a resource, not write an existing one. Does anyone have any clue on how to do this, google has yet again failed me.

I'm trying to do this

ZipFile.CreateFromDirectory(NewResource, MyResources)

Maybe I can't use createfromdirectory like that or that might not be how it works, but I want to save to my Resources. I just don't know how to,

DumbedDown: Click button, openfiledialog, choose .exe, it saves to resources for later use.


Also I've tried ResourceWriter and Adding a resource that way but as I stated I want to add actual Files, not just strings / text. Unless somehow I can manage it through memory or somethign idk.


Welp, I'm having a problem using a Boolean in a Loop with my Save to the fkn Folder Method.

Logic why do you fail me?
If you want to add a new resource to your executable at run time, that is impossible. Resources are stored in resx files, which is a custom XML structure, when images or binary files are added to the resx file, the bytes for the new item are stored in base64. The reason adding a new resource to your executable at run time is impossible, is actually because the resx file with all your resources is compiled into the resultiing binary. You would literally need to re-compile your application every time you want to change a resource.

If that is not what you want to do, ignore this post ;D
(Aug 20, 2015 04:49 PM)Nikey646 Wrote:  If you want to add a new resource to your executable at run time, that is impossible. Resources are stored in resx files, which is a custom XML structure, when images or binary files are added to the resx file, the bytes for the new item are stored in base64. The reason adding a new resource to your executable at run time is impossible, is actually because the resx file with all your resources is compiled into the resultiing binary. You would literally need to re-compile your application every time you want to change a resource.

If that is not what you want to do, ignore this post ;D

I want to add a new resource to my executable at run time.

My google adventures brought me across what you're talking about with resx files. There was something about using resXresourcewriter or some weird shit like that but I couldn't store actual files like Images or zip files to it only strings.

How do I make my program recompile it's self with a custom resx file that it adds to? I don't understand how this could be impossible, I mean physically adding files or copying them, into your file to store them shouldn't be "impossible".
You would have to code your own JIT compiler basically, if I'm not mistaken.
en . wikipedia . org/wiki/Just-in-time_compilation
Can someone give me an example please?
Like this?

Code
using (var writer = new ResourceWriter("mysettings.resources"))
{
    writer.AddResource("Example1", "Hello");
    writer.AddResource("Example2", 11);
    writer.AddResource("Example3", File.ReadAllBytes("Add.exe"));
    writer.Generate();
    writer.Close();
}
Lotta blood to let, peace to make, give a fuk about a check
(Aug 20, 2015 09:23 PM)BahNahNah Wrote:  Like this?

Code
using (var writer = new ResourceWriter("mysettings.resources"))
{
    writer.AddResource("Example1", "Hello");
    writer.AddResource("Example2", 11);
    writer.AddResource("Example3", File.ReadAllBytes("Add.exe"));
    writer.Generate();
    writer.Close();
}

Specifically not. I thought I CLEARLY covered that, guess not.


Possibly Related Threads...
Thread / Author Replies Views Last Post
by HackersFeb 12, 2025 11:02 PM 3 172 Feb 12, 2025 11:02 PM
Last Post: Phantom_NiNja
[C#] by GrootyAug 18, 2024 06:15 PM 1 201 Aug 18, 2024 06:15 PM
Last Post: Lookdadon
[Help] by john ronaldsadAug 18, 2024 05:58 PM 1 144 Aug 18, 2024 05:58 PM
Last Post: Lookdadon