C
C#14mo ago
Sher

❔ Read files from a library

I created a simle library using .NET 7. I have .json and .css files in this lib which I need to access during runtime. I tried to use
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
But files get copied to the library output directory, so the main project can't read them. I can access files using full path to them, but this way I will need to know the ralative path all the time, which I don't really like. How can fix the issue?
4 Replies
Mayor McCheese
Mayor McCheese14mo ago
What is reading the files? e.g. a browser, or you're using a .net assembly to ingest those files?
cypherpotato
cypherpotato14mo ago
your files should be copied to the output directory, period if any project is using your lib, these files should be copied to the main project output dir, with your .dlls too
reflectronic
reflectronic14mo ago
CopyToOutputDirectory does not actually do that it is actually pretty difficult to make this specific scenario work i agree, can you explain more about how these files are used. it will determine which options are good and which ones aren't
Accord
Accord14mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server