1. 程式人生 > >【C++】判斷檔案是否存在

【C++】判斷檔案是否存在

#include <iostream>
#include <fstream>

using namespace std;

int main( void )
{
     fstream _file;
     _file.open("./資料夾/*.dat", ios::in);
     if(!_file)
     {
          cout<<FILENAME<<"沒有被建立!"<<endl;
     }
     else
     {
          cout<<FILENAME<<"已經存在!"<<endl;
     }

     cin.get();
     return 0;
}

#include <Fileapi.h> //設定檔案屬性