win32 file I/O programming problem - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

win32 file I/O programming problem

SamBxSamBx Posts: 1Member
I have a weird win32 File I/O issue on a lab data collection/presentation system. When the operators told me
they were having sporadic issues like missing data, changes not taking, etc I suspected a file-writing error of some sort.
So I made up a little test
thread that every 5 minutes simply appends an "I am well" line to a text file as follows...

//============== called every 5 minutes from background thread
int XAppendTimeLine() //for debug purposes only
{ int bfsz,i,j=-99,k=-99,w=-99,r=-99,sfp=-99; HANDLE hfile; char buff[2000],err[200];
hfile=CreateFile("Marktime.txt", GENERIC_READ|GENERIC_WRITE,0,NULL, OPEN_ALWAYS,
FILE_ATTRIBUTE_NORMAL,NULL);
if (hfile==HANDLERR) {r=-1; goto finn;}
sfp= SetFilePointer(hfile,0,NULL,FILE_END);
sprintf(buff,"I am fine at %s

",strCurrDateTime(); bfsz=strlen(buff);
w=WriteFile(hfile,buff,bfsz,&k,NULL);
if (w==FALSE) r=-9999; else r=k;
j=CloseHandle(hfile); if (j==0) r=-8888;
finn:
sprintf(err,"",r,hfile,sfp,w,j);
Mywmdebug(err);
return r;
}
//==============


This little routine runs correctly for a few hours after app startup,
but after that no more lines get appended
to the file. However if I look
at my debug log output everything continues to appear as if its working; no error returns show up.
Strangely what I
see in the log streams is that sfp (the returned result of the SetFilePointer call)
continues to grow as if the data was properly written.

At this point Im clueless as to what is happening or what to try next. Any Ideas??

Comments

  • anthrax11anthrax11 Posts: 511Member
    It's a long shot, but maybe you're looking at the data using the old Windows 9x notepad, which only supports files up to 64kB..
Sign In or Register to comment.