Hi everyone
I'm new to c++ but have had some luck so far. But I have of course met a problem.
The program I'm making is supposed to find a a unkown file with an ID. The onliest thing I know of the file is the folder its in.
so I want to open every file in this folder and read them, to see if they have the ID. But I dont know how to do that.
this is what I got so far:
void FindFile(){
char pPathFolder[250];
char pPathCommunicator[251];
string FolderPath = "\\Documents\\logfiles"; // this is the folder with the file
string CommunicatorPath = "\\Documents\\FileCommunicator.txt";
char* pPathInit = getenv ("USERPROFILE");
char* pPathInitC = getenv ("USERPROFILE");
strcpy(pPathFolder,pPathInit);
strcat(pPathFolder,FolderPath.c_str());
strcpy(pPathCommunicator,pPathInitC);
strcat(pPathCommunicator,CommunicatorPath.c_str());
bool FileExists = false;
if (pPathFolder == NULL) {
cout << "Folder is NIL (Null)" << endl;
} else {
do{
if (file_exists("file.txt") == true){ // if the file exists
FileExists = true;
}
}
while (FileExists == false);
ofstream CommunicatorToFile;
CommunicatorToFile.open(pPathCommunicator);
CommunicatorToFile << "logfiles\\test.txt"; // then write the path to the file here
CommunicatorToFile.close();
}
}