❔ ✅ Equivalent of Java's resources folder in c#
I've been dipping my toes in c# for a while but i cant seem to find a proper way of storing files in the app itself, i use rider.
9 Replies
In project
1) Move files you need to store in app in project folder
2) Set ContentType of these files to
EmbeddedResource
These two steps will add files inside assemblyif i have a ton can i use a folder?
Yes, and wildcard paths are supported in
.csproj
file, not sure about Rider
In code
1) Get instance of Assembly
class that represents assembly in which files are stored:
2) Call
asm.GetManifestResourceNames()
to get an string[]
of all resource files in that assembly or
asm.GetManifestResourceStream(string)
to get Stream
to read that resourceimma try figuring outhow to set content type of a folder toembedded resource in rider
You can't set ContentType for folders. Use wildcards to set it for all files inside that folder:
Set ContentType for some file in that folder and then edit
.csproj
file to change path to that file to use wildcard
So will change to
Change *
to **
to recursively include all subdirectories and filesThank you so much :D
No problem. Also, $close if you have no more questions
Use the
/close
command to mark a forum thread as answeredWas this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.