This is a discussion on How do I specify a directory with ifstream and ofstream? within the C++ Programming forums, part of the General Programming Boards category; Originally Posted by laserlight Yes, but not with the standard library. You could consider the use of Boost.Filesystem . Where ...
It's part of the boost library available at the same site that hosts that doc page.
Streams are designed for what their name implies - streams. Just b/c it is a file stream does not mean it can navigate folder structures. That is normally up to the operating system. The C standard library as well as the Win32 API provide plenty of functionality for all of that.
If by "navigate folder structures" you mean access files that are outside the current directory, then I believe that it can, but the path name format is implementation defined, which in this case means operating system dependent. This is why I suggested the use of Boost.Filesystem as it provides a generally portable solution.Originally Posted by Bubba
I do not think that the C standard library has any advantage over the C++ I/O streams in this respect. The respective functions are also concerned about file names, not directory names or path names in general.Originally Posted by Bubba
Yes but you have such things as setcwd and getcwd and so forth that do interact with the file system. Just b/c you can specify a path for ifstream and ofstream does not mean they should be used for folder navigation.