<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'win32 file I/O programming problem' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'win32 file I/O programming problem' posted on the 'Windows programming' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2013 Programmers Heaven</copyright>
    <pubDate>Mon, 17 Jun 2013 23:45:58 -0700</pubDate>
    <lastBuildDate>Mon, 17 Jun 2013 23:45:58 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>win32 file I/O programming problem</title>
      <link>http://www.programmersheaven.com/mb/windows/417549/417549/win32-file-io-programming-problem/</link>
      <description>I have a weird win32 File I/O issue on a lab data collection/presentation system. When the operators told me &lt;br /&gt;
they were having sporadic issues like missing data, changes not taking, etc I suspected a file-writing error of some sort. &lt;br /&gt;
So I made up a little test&lt;br /&gt;
thread that every 5 minutes simply appends an "I am well" line to a text file as follows...&lt;br /&gt;
&lt;br /&gt;
//============== called every 5 minutes from background thread &lt;br /&gt;
int XAppendTimeLine()  //for debug purposes only&lt;br /&gt;
{ int bfsz,i,j=-99,k=-99,w=-99,r=-99,sfp=-99; HANDLE hfile; char buff[2000],err[200];&lt;br /&gt;
    hfile=CreateFile("Marktime.txt", GENERIC_READ|GENERIC_WRITE,0,NULL, OPEN_ALWAYS, &lt;br /&gt;
                                                    FILE_ATTRIBUTE_NORMAL,NULL);&lt;br /&gt;
    if (hfile==HANDLERR)  {r=-1; goto finn;}&lt;br /&gt;
    sfp= SetFilePointer(hfile,0,NULL,FILE_END);&lt;br /&gt;
    sprintf(buff,"I am fine at %s\n\r",strCurrDateTime(); bfsz=strlen(buff); 	&lt;br /&gt;
    w=WriteFile(hfile,buff,bfsz,&amp;amp;k,NULL);&lt;br /&gt;
    if (w==FALSE) r=-9999;  else r=k;&lt;br /&gt;
    j=CloseHandle(hfile);  if (j==0) r=-8888;&lt;br /&gt;
finn:&lt;br /&gt;
    sprintf(err,"&amp;lt;r=%d; han=%d  sfp=%d  w=%d  c=%d&amp;gt;",r,hfile,sfp,w,j);&lt;br /&gt;
    Mywmdebug(err);     &lt;br /&gt;
    return r;&lt;br /&gt;
}&lt;br /&gt;
//==============&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This little routine runs correctly for a few hours after app startup, &lt;br /&gt;
but after that no more lines get appended&lt;br /&gt;
to the file.   However if I look &lt;br /&gt;
at my debug log output everything continues to appear as if its working; no error returns show up.&lt;br /&gt;
Strangely what I &lt;br /&gt;
see in the log streams is that sfp (the returned result of the SetFilePointer call)&lt;br /&gt;
continues to grow as if the data was properly written.&lt;br /&gt;
&lt;br /&gt;
At this point Im clueless as to what is happening or what to try next.  Any Ideas??    &lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/windows/417549/417549/win32-file-io-programming-problem/</guid>
      <pubDate>Tue, 29 Jun 2010 07:41:38 -0700</pubDate>
      <category>Windows programming</category>
    </item>
    <item>
      <title>Re: win32 file I/O programming problem</title>
      <link>http://www.programmersheaven.com/mb/windows/417549/417555/re-win32-file-io-programming-problem/#417555</link>
      <description>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..</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/windows/417549/417555/re-win32-file-io-programming-problem/#417555</guid>
      <pubDate>Tue, 29 Jun 2010 15:44:39 -0700</pubDate>
      <category>Windows programming</category>
    </item>
  </channel>
</rss>