title: IO.FileNotFoundException but File should exist
body: <p>I'm getting a suprising <code>FileNotFoundException</code> although i'm sure that the file exists.</p>
  
  <p>I simply wanted to add Logfiles(<code>IO.FileInfo</code>) as attachments to an email, therefore i tried to check the length of every file to detect if they must be added/zipped.
  <strong>This works fine if these files already exist</strong>. 
  But if i've created them in this run, i get above exception when i try to check the length. It's oddly enough that i can write into these "not existing" files(actually <code>FileInfo.Exists</code> returns <code>false</code>) without a problem one line before.</p>
  
  <p>Here is some code...</p>
  
  <p>Creating one of the files in the constructor of a class named <code>Log</code>:</p>
  
  <pre><code>Me.LogFile = New IO.FileInfo(infoLogPath)
  If Not LogFile.Exists() Then
     'tried to use `Using` on the Stream but that doesn't change anything'
     Using stream = Me.LogFile.Create()
         'close and dispose implicitely
     End Using
  End If
  </code></pre>
  
  <p>I can write into the file without a problem:</p>
  
  <pre><code>Me.Log.WriteInfo("BlahBlahBlah...", False)
  </code></pre>
  
  <p>One line after i'm getting the exception on <code>LogFile.Length</code>:</p>
  
  <pre><code>If Me.Log.LogFile.Length &lt;&gt; 0 Then
      files.Add(Me.Log.LogFile)
  End If
  </code></pre>
  
  <p><code>Me.Log</code> is a custom logging-class object named <code>Log</code> that holds the reference to the <code>FileInfo</code> object.</p>
  
  <p>This is <code>WriteInfo</code> in class <code>Log</code>, <code>LogFile</code> is the <code>IO.FileInfo</code>-onject:</p>
  
  <pre><code>Public Sub WriteInfo(ByVal message As String, ByVal finishLog As Boolean)
      Try
          Using w As IO.StreamWriter = Me.LogFile.AppendText
              If Me.WithTimestamp Then
                  w.WriteLine(Date.Now.ToString(Globalization.CultureInfo.InvariantCulture) &amp; ": " &amp; message)
              Else
                  w.WriteLine(message)
              End If
              If finishLog Then w.WriteLine("__________________________")
              w.Flush()
              w.Close()
          End Using
      Catch writeLogException As Exception
          Try
              WriteError(writeLogException, True)
          Catch innerEx As Exception
              'ignore
          End Try
      End Try
  End Sub
  </code></pre>
  
  <hr>
  
  <p>Actually <a href="https://stackoverflow.com/questions/6939893/io-filenotfoundexception-but-file-should-exist/6940101#6940101">@ShellShocks solution</a>  with <a href="http://msdn.microsoft.com/en-us/library/system.io.filesysteminfo.refresh.aspx" rel="nofollow noreferrer">Refresh</a> was simple. Never heard of this function, strange that i get a FileNotFoundException when i don't refresh the file.</p>
  
  <pre><code>Me.Log.LogFile.Refresh()
  </code></pre>