How can I embed and use a .txt file as a resource in a C # class library project (VS2012)?

I searched quite a lot, but I did not find a solution to this seemingly easy problem.

I can add a TXT (CSV) file with the name "CSVData.txt" as a resource to the console application project and access it using the namespace easily - he named "CSVData" in the project.

string Temp = Properties.Resources.CSVData; 

But when I create the class library project, I cannot: apparently, there is nothing in the Properties.Resources namespace, even if it was created successfully in the same way as in the Console Application project.

It is checked several times by new projects with identical results.

I am sure that this is something very, very simple, but I can’t let life show me on this.

+4
source share
1 answer

Most likely, the problem is that the access modifier for the resource file by default = internal, which means that it is visible only inside the dll. Go to the resource page and try changing it to Public:

enter image description here

+3
source

Source: https://habr.com/ru/post/1486313/


All Articles