   How to check if a file doesn't exist?
  I use the following code to open and read a file (please ignore the fact that there are no std::''s):quote:long size = 37390;unsigned char  buffer[size];ifstream file (filename, ios::in|ios::binary|ios::ate);file.seekg (0, ios::beg);file.read (buffer, size);file.close();But I don''t know how to check wether or not the file actually exists, how can that be done?Thanks. 
  Here''s my code for checking the existence of a file.. I put it in a separate method: bool CFichero::fileExists(){if (filePath!=""){   ofstream aux(filePath, ios_base::in);if(!aux)  // if file does not exist...{return false;    }else{   // If file exists...aux.close();    // ...close itreturn true;}}else{// If the filePath is empty, errorcerr<<"[CFile]: filePath==\"\""<<endl;return false;}}Hope that helps... ---"To Iterate is human, To Recurse Divine..." ;FILE * f = fopen(fileNameString, "rb");if(f != 0) {  fclose(f);  // File Exists.} else {  // File does NOT exist.};;  You can also do it like this I think...a little easier to read.if(!file.is_open())   //something wrong   doing it like "if(!file)" will work as well though... [edited by - NullPointer33 on February 19, 2004 7:29:17 PM];ifstream in;in.open("filename", ios::nocreate);if (!in){  // no file exists"} "A soldier is a part of the 1% of the population that keeps the other 99% free"  - Lt. Colonel Todd, 1/38th Infantry, Ft. Benning, GA ;  boost::filesystem::exist   - Magmai Kai HolmlorNot For Rent[Look for information | GDNet Start Here | GDNet Search Tool | GDNet FAQ | MSDN RTF[L] | SGI STL Docs | STFW | Asking Smart Questions ][Free C++ Libraries | Boost | ACE | Loki | MTL | Blitz++ | wxWindows| Spirit(xBNF)][Free C Libraries | zlib ];  There''s no need to open the file to see if it exists.#include <io.h>bool bExists = _access("filename.txt", 0) == 0; 