I have a text file containing a list of files seperated by line. I'm trying to open each file, and then process the data within each, however the ONLY file that successfully opens is the LAST file in the list. Any idea why this is happening?
input file looks like this:
Microsoft Office Professional Plus 2010.txt
Microsoft Office OneNote MUI (English) 2010.txt
Microsoft Office InfoPath MUI (English) 2010.txt
Microsoft Office 2010 Primary Interop Assemblies.txt
Microsoft Office Access MUI (English) 2010.txt
Source code:
void loadCVEDescription(char* CVEDescList) {
vector<string> fileList;
ifstream inputFile(CVEDescList);
string descfile = "";
while(!inputFile.eof()){
getline(inputFile,descfile);
descfile = "C:\\path\\path\\" + descfile;
fileList.push_back(descfile);
}
inputFile.close();
for(size_t t = 0; t < fileList.size(); t++){
ifstream dataFile;
string pname = descfile.substr(descfile.find_last_of("\\")+1,descfile.find(".txt"));
int i = findProductIndex(pname);
/*
findProductIndex(string pname) searches product[] and returns the index
at which products[i].productName matches pname
*/
dataFile.open(fileList[t]);
if(dataFile.is_open()){
cout << fileList[t] << " success" << endl;
}
dataFile.close();
dataFile.clear();
}
}
The ONLY file which successfully opens is the LAST one in the input file.