I am trying to figure out this and its bugging me for a long now.
when i type:
inFile.open("C:\Users\Mark\Desktop\text.txt", ios::in | ios:: binary);
it works just fine. But when i do something like this.
string garbage = "\\";
srcLoc = ofn.lpstrFile; // this is: C:\Users\Mark\Desktop\text.txt
// This for loop inserts "\\"
for(int i = 0; i < srcLoc.length(); i++)
{
switch(srcLoc[i])
{
case '\\':
srcLoc.insert(i, garbage);
i++;
break;
}
}
// Now string srcLoc looks like: C:\\Users\Mark\\Desktop\\text.txt
inFile.open(srcLoc.c_str(), ios::in | ios:: binary);
// But it wont work
if(inFile)
{
while(!inFile.eof())
{
getline(inFile, tekst);
SendMessage(hTextBox, EM_REPLACESEL, 0, (LPARAM)tekst.c_str());
SendMessage(hTextBox, EM_REPLACESEL, 0, (LPARAM)"\r\n");
}
}
else
{
MessageBox(0, srcLoc.c_str(), "Could not load", MB_ICONWARNING | MB_OK);
}
inFile.close();
What i get is MessageBox "Could not load" working at least :) Anyone know what i am missing?