Opening a file
Hi guys, I have created a console program and for one part of it I allow the user to open a txt file by entering the file path of the file i.e C:\file.txt but i was just wondering is there an easier way to allow the users to open files?
Thanks in advance for any advice.
You can do either of 2 things, assume the file is going to be in a certain directory (not so great if you are going to distibute) or try and use relative file paths. You can just put in the name of the file if it is in the same directory as the executable (and you are running the executable from that directory and not your IDE) and it will attempt to load from the working directory, which USUALLY is the one the executable is ran from.
The first method will work if it is just you, or the program installs to a certain directory such as C:\Program Files\%PROGRAM NAME%\ and you want to always load a save from the sub directory \save . The working directory is no garrentee so use that with caution.