fix access of files relative to the program directory #106
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I had some issues with the
res
directory not being found correctly when my working directory was somewhere else than the project.For example, doing
dotnet run --project Fushigi/Fushigi.csproj
from the root of the repository when you don't have animgui.ini
file in your current directory will crash the app.If you have
-c Release
set, it will silently crashThe problem is with paths being relative to the working directory instead of the app directory (where the res directory and the .dll files are)
I saw that there was a line in the code which prepended
AppDomain.CurrentDomain.BaseDirectory
before "res"and there was another line which prepended
AppContext.BaseDirectory
These both solved the problem
According to this, there's no difference between them
https://learn.microsoft.com/en-us/dotnet/api/system.appcontext.basedirectory
Sadly I can't really test it out, as I couldn't properly setup my game files...
I'd be happy if someone could test if this works as expected