Sierraffinity / GBAIntroManager

Edits the intro sequence for Pokémon 3rd generation games.
GNU General Public License v3.0
6 stars 3 forks source link

INI files cannot be found #2

Closed Ayanami3rd closed 6 years ago

Ayanami3rd commented 6 years ago

MainWindow.cs: Line 20 and Line 78

Always tries to find INI files in C:\Hacking....

Workaround: Works if I hardcode the path

Solution: Use proper path variables

Sierraffinity commented 6 years ago

AppDomain.CurrentDomain.BaseDirectory should always return the directory where the executable file is located. What do you think would be a "proper path variable" to use instead?

Ayanami3rd commented 6 years ago

I'm neither a VS nor a C# pro, but AppDomain.CurrentDomain.BaseDirectory does not work for me.

What does work is for instance Directory.GetCurrentDirectory() - line 78:

if (!ParseINI(System.IO.File.ReadAllLines(Directory.GetCurrentDirectory() + "/ GBAIntroManager.ini"), gameCode))

Sierraffinity commented 6 years ago

I'm using AppDomain.CurrentDomain.BaseDirectory because it will always return the location of the EXE file, regardless of the current working directory (which could differ). What does AppDomain.CurrentDomain.BaseDirectory return for you, and what should it actually return?

Ayanami3rd commented 6 years ago

Line 20 - characterValues = ReadTableFile(AppDomain.CurrentDomain.BaseDirectory + "/Table.ini");

generates the following error

gbaerror

The file is actually located on my PC in D:\Spiele\Emulatoren\VisualBoy Advance\hack\GBA-Intro Manager\GBAIntroManager\

Interestingly, AppDomain.CurrentDomain.BaseDirectory works in line 78:

if (!ParseINI(System.IO.File.ReadAllLines(AppDomain.CurrentDomain.BaseDirectory + "/ GBAIntroManager.ini"), gameCode))

Edit: Corrected a path,

Sierraffinity commented 6 years ago

Okay, that seems to have been a leftover from the output path I had (make sure it didn't create those folders on your C drive). I've pushed a change, try that?

Ayanami3rd commented 6 years ago

Unfortunately, the path is still not 100% correct. For me, it should be

D:\Spiele\Emulatoren\VisualBoy Advance\hack\GBA-Intro Manager\GBAIntroManager\Table.ini

But the program searches the INI file in

D:\Spiele\Emulatoren\VisualBoy Advance\hack\GBA-Intro Manager\GBAIntroManager\bin\Release\

See attachment. gbaerror2

Sierraffinity commented 6 years ago

Well that's because the executable, when you build it, is located in bin/Release. You need to copy the INI files into that folder. This is expected behavior.

Ayanami3rd commented 6 years ago

Reasons why Visual Studio is not intuitive sometimes.

I resolved the problem by creating symbolic links for the INI files in the \bin\Release folder. Works fine now.