+ 5

how to open a specific file location?

rather then the same folder as the program.

12th Apr 2017, 4:45 AM
DeleteThisAccount
2 Respostas
+ 2
On Windows, you can ifstream myFile; myFile.open("C:\\Path to\\MyFile.txt"); Note the double backslashes avoiding the backslash being interpreted as an escape character (as in e.g. "\n"). I think you can also use forward slashes on Windows. In Linux, I guess you can specify an absolute path by starting with a /: ifstream myFile; myFile.open("/etc/Path to/MyFile.txt"); To give paths relative to your executable, you can move one directory up with "..": ifstream myFile; myFile.open("..\..\MyFileTwoDirectoriesAboveExe.txt");
12th Apr 2017, 5:47 AM
Jo_
Jo_ - avatar
+ 3
specify the absolute path of the file you want to work with. if you want to open a folder in a new window send a command using system("start c:\yourFolder"); in your C++ program.
12th Apr 2017, 8:12 AM
seamiki
seamiki - avatar