Opening a txt file outside of your C++ project

closed account (365X92yv)
Here's my dilemma. I have a txt file that is linked with a game I play. I can read in from this file and grab data from it. The only problem with this is the txt file has to be in the project folder for it to get it. What I need to be able to do is give the user the ability to declare when running the program where the file is and then open it. I know this isn't impossible because almost every computer program has this. Its the little "browse" button you can click. Anyways, I'm just wondering what the syntax would be, as well as, the method in which to do this. It can't be something that's hardcoded, such as a file name that you just put in the cpp file. Its got to be something like a browse and select feature that can be user side. Thanks if you understand what I want.
There's one API GetOpenFileName. Try searching in MSDN. I myself have the code, and will give you if you want. But I'd like to see you trying a little
closed account (365X92yv)
I looked it up but its pretty beyond where I'm at as far as my knowledge of C++ goes.
All you need to do is pass the path to the file to ifstream::open(). It's not limited to opening files in the same directory as the executable*. :)

*Technically, the correct statement is that ifstream isn't limited to opening files in the present working directory.

-Albatross
closed account (365X92yv)
Alright. That works. Thanks.
Topic archived. No new replies allowed.