Possible Duplicate:
How to embed a text file in a .NET assembly?
I have a c# winforms application that use several text files.
I would like to somehow embed those files either into the exe or dlls, so that they cannot be seen by the user when the application is deployed.
Can visual studio do something like that?
With text files you can also proceed as following:
Properties
-> Resources.resx
file to open the resource designer.Add Resource
-> Add Existing File...
and select your text files.Let's say that the TXT you added was called Foo.txt
... you can just access it's content like so:
String foo = Properties.Resources.Foo;
Then you can also change te file names inside the resource designer and they will be automatically refactored in your code. From the Resources
directory, where they are now located in your project, you can also edit them.
I just recommend you to keep their access level as internal
.
Here's how I do it:
Properties.Resources.YourFileName
.Be wary: Visual Studio will copy your chosen file into your project's Resources folder. It will not create a link to wherever the file was originally stored.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With