I try to load a file with fstream. The code looks like this
file.open("../levels/level0.lvl");
if (file.is_open()) {
while (!file.eof()) {
std::getline(file, Str);
list = ReadLine(Str, list);
}
}
But it loads nothing. Yes only if the path is absolute. How can I make the path relative?
The folder "levels" is hosted in the debug folder. same folder as the exe.
"The folder "levels" is hosted in the debug folder. same folder as the exe."
It doesn't matter in which position the levels
folder is in relation to the executable's path.
The relevant folder to determine the relative path is the working directory where your executable is actually started from.
See here: fstream doesn't resolve path also.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With