Thread: Opening a file

  1. #1
    Registered User
    Join Date
    Oct 2005

    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
    Portland, Or
    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
    Registered User
    Join Date
    Oct 2005
    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, 07: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, 06:39 AM
  5. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 04:10 PM