sclang
sclang

Reputation: 229

c# class library use files

I'm building a class library which use a .dat file, inside the library i made a folder App_Data and put the .dat file inside it, how can i have my library to use the .dat file. How could it be included at the dll when build?

I already tried Path.GetFullPath, and almost anything in Path, but all i get is the path to debug folder, and in that folder i dont even have the .dat file which i expect to be included because the .dat file is in the project.

I just want to use that .dat file without hard coding its path, and it should still work when referenced.

Upvotes: 3

Views: 2444

Answers (1)

Leniel Maccaferri
Leniel Maccaferri

Reputation: 102428

You must right-click the .dat file and set Copy to Output Directory = Copy Always. Doing so, the path to the debug folder will correctly point to the file. No need to hard code the path.

enter image description here

If you're interested in embedding the .dat file in the DLL (a bit more work), you can go this way:

Can I embed other files in a DLL?

Upvotes: 5

Related Questions