Hi Everyone,

I am new user for this community and as a trend when we are in trouble then we remember friends.
Don't mind .

My Question: My application creates trace.txt file which contain debugging information when app. is running but in real production there may be a problem because there trace files are created on another system using MAP drive and if there is a network failure then windows shows an eror dialog box> " Windows Delayed Write failed .... " to create a txt file we are using fprintf().

What i expect after restore a network connection it should work proper but right now i think they have to restart an application which is really BAD.

Can any body help me ?

Thanks
Nishant Soni
ISC Software PVT Ltd.
INDIA

> What i expect after restore a network connection it should work proper
the problem is that the FILE structure that is being passed to fprintf is no longer usable. it contains an operating system file descriptor (handle) which is not valid any more. you really do not need to restart the application. instead you could just close the file and reopen it afresh. (perhaps have a background thread waiting on an event to do this at the right time).

I had same doubt in mind so i check File pointer each time whenit pass to a fprintf() and it is valid
i am checking like
if (TraceFilePinter != 0)
{
fprintf(TraceFilePointer,"Information");
}
is there any other way to test it.

that's the wrong test for this problem. The file pointer is only invalid, very similar to using an unitialized pointer.

>>is there any other way to test it.
Probably check the return value of fprintf(). If it failed then most likely you have the problem you are describing.

If an output error is encountered, a negative value is return

The way I got around this was to open the file before each write then close it again after the writes were finished -- this was a logging program.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.