This code should be complete but I cant get it what the problem is. It is a very strange thing that happening. I might need a professional eye to see if the problem could be found :)
The problem is this:
The mainthing is that I am using a for loop to go through 5 .txt file paths that I have read in into a vector called: "ReadInGroup" from a .txtfile (NewDataGroup.txt)
The lines in this file NewDataGroup.txt look like this, so this should be correct:
C:\Documents and Settings\Jennifer\Desktop\New Data\Hello1.txt
C:\Documents and Settings\Jennifer\Desktop\New Data\Hello2.txt
C:\Documents and Settings\Jennifer\Desktop\New Data\Hello3.txt
C:\Documents and Settings\Jennifer\Desktop\New Data\Hello4.txt
C:\Documents and Settings\Jennifer\Desktop\New Data\Hello5.txt
Now is the funny this. The while loop reads in the path-lines in the vector as it should do. This works!
(Below I also have the 5 paths between /* */
So the for loop should now loop through one file at a time and read these files and a little futher down in the code I use a while loop to read in all data in these files into a vector.
The for loop goes through the 5 files above though I have used a messagebox to confirm it before.
The funny here is that the for-loop goes through the 4 first files above very fast, then stops at the last file(Hello5.txt) and do read in this files data into a vector. (Why the last file, very strange ? This meens it works in a way)
Now, I have specified manually the filenames/paths below between /* */
(Hello1.txt - Hello5.txt) as a test to see what happens ?
So if you take these /* */ away, this will mean that the already read in vector ReadinGroup will replace with the manually specified paths as I have done below.
If I do this, then it goes through all 5 files and read all 5 files into the vector as it should do.
So the code is correct done but something is missing.
What is the difference, Why does it work when I manually specify the pathway to the files and not when I have read them in, into the vector.
In both cases the for loop will read from the same 5 elements.
I really have no clue on this one.
std::string Dummy;
std::string Dummy2;
std::string FileName1;
std::string FileName2;
std::string FileName3;
ifstream NewDataGroup2("C:\\Globe\\Append Groups\\NewDataGroup.txt");
std::vector<string> ReadInGroup(10000);
std::string ReadIn;
int countGroup = 0;
while( getline(NewDataGroup2, ReadIn, '\n') )
{
countGroup = (countGroup + 1);
ReadInGroup[countGroup] = ReadIn;
}
/*ReadInGroup[1] = "C:\\Documents and Settings\\Jennifer\\Desktop\\New Data\\Hello1.txt";
ReadInGroup[2] = "C:\\Documents and Settings\\Jennifer\\Desktop\\New Data\\Hello2.txt";
ReadInGroup[3] = "C:\\Documents and Settings\\Jennifer\\Desktop\\New Data\\Hello3.txt";
ReadInGroup[4] = "C:\\Documents and Settings\\Jennifer\\Desktop\\New Data\\Hello4.txt";
ReadInGroup[5] = "C:\\Documents and Settings\\Jennifer\\Desktop\\New Data\\Hello5.txt";*/
for (int Starting = 1; Starting < (countGroup + 1); Starting++)
{
std::vector<string> ReadInData;
ifstream ReadFile(ReadInGroup[Starting].c_str());
FileName1 = ReadInGroup[Starting].substr(ReadInGroup[Starting].rfind("\\")+1);
FileName2 = Files16.c_str();
FileName3 = FileName2 + "\\" + FileName1; //FileName1 Substr
ifstream FindFile( FileName3.c_str() ); //specify file in path
String^ Symbol10 = gcnew String(FileName1.c_str());
//All Data in this particular .txt File is in memory with this loop !
while( getline(FindFile, Dummy2, '\n') )
{
ReadInData.push_back(Dummy2);
}
//Continue To fill this vector up with other data
while( getline(ReadFile, Dummy, '\n') )
{
ReadInData.push_back(Dummy);
}
} //End Foor Loop