DEV Community

Calin Baenen
Calin Baenen

Posted on

How can I include resources in a compiled C# program for later use?

I want something similar to the effect of how Jar files retain data (as they are like zip files).
Since this is not the case w/ CSharp, how can I include resources?

Here's an example of what I want to do (this is meant to be a filesystem):

Project:
 Main.cs
 Components:
  JSONHandlers.cs
  JSON:
   myFile.json
   one.json
   two.json
Enter fullscreen mode Exit fullscreen mode

Now, let's say I want to read one.json from the compiled output (Project.exe), as far as I'm aware, files like these aren't included in the end-product, and it doesn't create a file for this, so if I try to read that file, it will throw an exception.

Another example is if I have a folder of resources (images, dialogue, etc...) (in a game-dev ctx), and I tried to use those.
So, is there any way of packaging these resources with the executable?

Thanks!
Cheers!

Top comments (3)

 
baenencalin profile image
Calin Baenen

It doesn't say how to do this in the .csproj file, could you provide a url to an example of an uncompiled program that will have something packaged inside of it?
Solutions for V.S. seem to be more popular than the barebones method of CLI and .csproj (but I guess that's to be expected with all these fancy tools).

Collapse
 
baenencalin profile image
Calin Baenen

Is there any way I can do this w/ just the dotnet CLI?
I don't use V.S., and don't know if it's a requirement or not, to get it working, as it doesn't say anything about doing it w/o V.S.

Thank you for the link to this post.
Cheers.

 
baenencalin profile image
Calin Baenen

TY a ton.
Cheers.