Posted on 2001-06-15
In the below given code, I have already opened a file with pFile, then i open a second file with CFile local
and keep reading from the pFile object and writing the same data to CFile local. Basically i'm copying one file to another.
In the While loop used in the below code i want to compare the Total File size of pFile with the total data written to CFile local,and exit the loop as soon as both the values are equal i.e. when data has been completely copied from file1 to file2. But the while loop is not functioning as it should be, it comes to a premateur end.
I know i can use While(nRead>0) instead of what i have used, But i want to exit the loop by comparing the two values. But i can't figure out why it isn't working.
Any suggestions ?
///////// Code Begins ///////////
CFile local(test_file_name,CFile::modeCreate|CFile::modeNoTruncate |CFile::modeWrite |CFile::typeBinary );
UINT nRead = pFile->Read(szBuff, 100);
nRead = pFile->Read(szBuff, 100);