Thread: How to Know if a file exists...

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    28

    How to Know if a file exists...

    Hi

    I am currently making a game that has an option where you can create new playeyes by creating txt documents and saving them as a format.
    If I know what I want to open I can read the file but how do I know how many files are in the format and open each one seperatly??
    Thanks
    ...

  2. #2
    Frustrated Programmer :( phantom's Avatar
    Join Date
    Sep 2001
    Posts
    163
    if I have read your question right then this may help ->

    //assuming that the file of player 01 is called player01

    if(player01)
    {
    //if the file name is in the 'if' statement then it will only do
    // this, if the filename doesn't exist then it won't do this
    }

    hope this helps
    My site to register for all my other websites!
    'Clifton Bazaar'

  3. #3
    Registered User
    Join Date
    Sep 2001
    Posts
    412
    I think what he's asking is how to enumerate an arbitrary number of arbitrarily named files ending in a single extension.

    E.g. he wants to read ALL text files in a directory, but won't know the name or number beforehand.

    Look at the findfirst() and findnext() functions -- I think this is what you need.
    Last edited by The V.; 09-27-2001 at 12:44 AM.

  4. #4
    Frustrated Programmer :( phantom's Avatar
    Join Date
    Sep 2001
    Posts
    163
    ooops....

    I would have an option in the game to make a player and then make the file with the new players name.

    I can't think of anyway to help with your method
    My site to register for all my other websites!
    'Clifton Bazaar'

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A development process
    By Noir in forum C Programming
    Replies: 37
    Last Post: 07-10-2011, 10:39 PM
  2. sequential file program
    By needhelpbad in forum C Programming
    Replies: 80
    Last Post: 06-08-2008, 01:04 PM
  3. 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
  4. help with text input
    By Alphawaves in forum C Programming
    Replies: 8
    Last Post: 04-08-2007, 04:54 PM
  5. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM