I want to load a yaml
file from outside the working directory. I use c++
. I used YAML::LoadFile("/home/example.yaml")
and it complains YAML::BadFile
. Please let me know if there is any way to do that.
Asked
Active
Viewed 672 times
1 Answers
1
YAML::LoadFile
does nothing else than reading the file via std::ifstream
. So your actual problem is that you cannot open the file at all in your application.
Check whether the file exists and has the proper permissions so that your application may open it. Try opening it directly with a std::ifstream
and hand that over to YAML::Load
so you can inspect the stream directly to see what error occurred.

flyx
- 35,506
- 7
- 89
- 126
-
I can open as well as read/write the yaml file as long as it is in the build folder of the package. – code_fun Mar 07 '18 at 22:32
-
ok, now with ifstream and Load, I can read the file but if I write something, it is not reflecting in the original file. To be frank, if I read from anywhere outside, it is reading and then I keep the location of the file to write to, in the build folder, it just writes only a small part which I modified in the file from that I read. – code_fun Mar 07 '18 at 22:44
-
ok, it's fine now. I made a mistake in addressing the right path while trying to access from outside the directory. – code_fun Mar 07 '18 at 23:42