// FileExists take 2
// By DreamVB  19:21 28/09/2016

#include <iostream>
#include <Windows.h>

using namespace std;
using std::cout;
using std::endl;

bool FileExists(string Filename){
	//INVALID_HANDLE_VALUE
	WIN32_FIND_DATAW wfd;
	bool Found = false;
	wstring wfile(Filename.begin(), Filename.end());
	HANDLE fh = FindFirstFile(wfile.c_str(), &wfd);
	Found = (fh != INVALID_HANDLE_VALUE);
	FindClose(fh);
	return Found;
}

int main(int argc, char *argv[]){

	//Location of log file.
	string LogFile = "C:\\ben\\log.txt";

	cout << "Filename  : " << LogFile.c_str() << endl;
	cout << "Exists    : " << FileExists(LogFile) << endl;

	system("pause");
	return 0;
}