C
C#3y ago
DaVinki

How to use relative path in referenced project within same solution?

I made a project for a simple Person object. In this project, I include a resources directory that contains a names.txt. I use a relative path to the text file in my Person project but when I run the program, the directory isn't correct. The path is Person/Resources/names.txt but comes out to be SolutionDirectory\bin\Debug\net6.0\Person\Resources\names.txt in the error where the entire relative path doesn't exist. It ends at net6.0. Is there a way I can include resources from other projects into the running project's bin?
1 Reply
DaVinki
DaVinkiOP3y ago
Unhandled exception. System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Users\Landon\RiderProjects\TestSolution\TestProject\bin\Debug\net6.0\Person\ Resources\names.txt'. How would I do that? That worked Sort of worked names.txt is in the output dir now But the first part of the relative path is missing, \Person\ Nevermind I removed that part from the relative path That fixed it Yeah I'm not sure about project naming conventions in C# so I just called it Person I'll remember that, thank you
Want results from more Discord servers?
Add your server