Opening a file

This is a discussion on Opening a file within the C++ Programming forums, part of the General Programming Boards category; Hi guys, I have created a console program and for one part of it I allow the user to open ...

  1. #1
    182
    182 is offline
    Registered User
    Join Date
    Oct 2005
    Posts
    133

    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.

  2. #2
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    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.

  3. #3
    182
    182 is offline
    Registered User
    Join Date
    Oct 2005
    Posts
    133
    Thanks for the advice.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Data Structure Eror
    By prominababy in forum C Programming
    Replies: 3
    Last Post: 01-06-2009, 09:35 AM
  2. To find the memory leaks without using any tools
    By asadullah in forum C Programming
    Replies: 2
    Last Post: 05-12-2008, 08:54 AM
  3. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM
  5. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 05:10 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21