How to hide pictures from the 'Resources' folder?

2

How do I create a file to put the images in the 'resources' folder? I do not want people using my program to have access to them. The file can be any extension.

    
asked by anonymous 06.02.2014 / 12:58

1 answer

6

Do you want to hide project resources? You can embed / embed them in assembly.

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

Thenyoucanreadthefileasfollows(ifitisatextfile):

varassembly=Assembly.GetExecutingAssembly();varresourceName=assembly.GetName().Name+".ficheiro.txt";

using (Stream stream = assembly.GetManifestResourceStream(resourceName))
using (StreamReader reader = new StreamReader(stream))
{
    string result = reader.ReadToEnd();
}
    
06.02.2014 / 13:02