判断文件是否存在

#pragma once
#include <iostream>
#include <string>
#include <Windows.h>
#include <fstream>
#include <signal.h>
#include <io.h>
#include <vector>
using namespace std;


bool existsFile(string FileName) {
fstream temp(FileName);
bool ret = temp.good();
temp.close();
return ret;
}
int main()
{
std::cout << "Hello World!\n";
if (existsFile("123")) {
system("echo pass_show");
system("type 123");
}
else
{
system("echo fail_show");

}
}

posted @ 2021-06-28 09:15  江南王小帅  阅读(70)  评论(0)    收藏  举报