-
April 6th, 2009, 10:57 AM
#1
WriteFile/ReadFile repeat last lines
Hi
Code:
do
{
bReadSuccess = ReadFile( hFile, strBuffer, sizeof(strBuffer), &nRead, NULL);
bWriteSuccess = WriteFile( hFile2, strBuffer, sizeof(strBuffer), &nWrite, NULL);
}while(bReadSuccess && bWriteSuccess && (nRead > 0));
a.txt's last line is:
315614,05r re regf
b.txt's last lines are:
315614,05r re regf
315614,05r re regf
315614,05r re
What is wrong with that loop?
Thanks.
Last edited by sawer; April 6th, 2009 at 10:59 AM.
-
April 6th, 2009, 11:04 AM
#2
Re: WriteFile/ReadFile repeat last lines
nRead doesn't has to be sizeof(strBuffer) if the buffer isn't fully filled, this probably creates the wierd lines. You are writing more that you read.
Last edited by Skizmo; April 6th, 2009 at 11:07 AM.
-
April 6th, 2009, 11:13 AM
#3
Re: WriteFile/ReadFile repeat last lines
Understood.
Solved it:
Code:
do
{
bReadSuccess = ReadFile( hFile, strBuffer, sizeof(strBuffer), &nRead, NULL);
bWriteSuccess = WriteFile( hFile2, strBuffer, nRead, &nWrite, NULL);
}while(bReadSuccess && bWriteSuccess && (nRead > 0));
Thanks
Last edited by sawer; April 6th, 2009 at 11:16 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|