How to hide images from 'Resources' folder?

Asked

Viewed 268 times

2

How do I create a file to put the images in the 'Resources' folder? I don’t want the people who use my program to have access to them. The file can be any extension.

1 answer

6


You want to hide resources from the project? You can embed/embed them in Assembly.

Just go the file properties inside Visual Studio, and where it says Build Action, select Embedded Resource.

inserir a descrição da imagem aqui

Then you can read the file as follows (if it is a text file):

var assembly = Assembly.GetExecutingAssembly();
var resourceName = assembly.GetName().Name + ".ficheiro.txt";

using (Stream stream = assembly.GetManifestResourceStream(resourceName))
using (StreamReader reader = new StreamReader(stream))
{
    string result = reader.ReadToEnd();
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.