Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I embed and use a .txt file as resource in a C# Class Library Project (VS2012)?

I have looked for quite a bit but I haven't found a solution to this seemingly easy problem.

I am able to add a TXT (CSV) file named "CSVData.txt" as resource in a Console Application project and access it using the namespace easily - it's named "CSVData" in the project.

  string Temp = Properties.Resources.CSVData;

But when I create a Class Library project, I cannot: apparently there's nothing in the namespace "Properties.Resources", even though it is created successfully just as in the Console Application project.

Tested multiple times with fresh projects with the same results.

I'm sure it's something very, very simple, but I can't for the life of me figure this one out.

like image 949
mkvlrn Avatar asked Oct 22 '22 07:10

mkvlrn


1 Answers

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

enter image description here

like image 121
VladL Avatar answered Nov 15 '22 05:11

VladL