Checking to see if a file exists...

This is a discussion on Checking to see if a file exists... within the C++ Programming forums, part of the General Programming Boards category; How do I check to see if a file exists, then create on if it doesn't? I've been searching and ...

  1. #1
    Registered User
    Join Date
    Jul 2002
    Posts
    18

    Exclamation Checking to see if a file exists...

    How do I check to see if a file exists, then create on if it doesn't? I've been searching and trying different things to no avail. Is their a 'FileCreate' somewhere that I can use, or something like it?

    Mark
    Language: C++
    Compiler: Borland C++
    OS: Windows NT

  2. #2
    Registered User
    Join Date
    May 2002
    Posts
    317
    if you are just going to create a file automatically if one doesn't exist just:
    Code:
    fstream myfile;
    myfile.open("File.txt",ios:: out|ios:: in);
    By default the OS will create a file if it does not find one, you'd actually have to add ios:: nocreate if you didn't want it to.

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, 11:39 PM
  2. File transfer- the file sometimes not full transferred
    By shu_fei86 in forum C# Programming
    Replies: 13
    Last Post: 03-13-2009, 01:44 PM
  3. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 01:13 AM
  4. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 10:46 AM
  5. checking values in a text file
    By darfader in forum C Programming
    Replies: 2
    Last Post: 09-24-2003, 03:13 AM

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