title: How to File.Exists in Nunit Test
body: <p>I have a method which tests for the existence of a file prior to carrying out some manipulation of file content as follows:</p>
  
  <pre><code>Private Sub AddHeaderToLogFile()
      ''#Only if file does not exist
      If Not File.Exists(_logPath) Then
          Dim headerLogger As Logger
          headerLogger = LogManager.GetLogger("HeaderLogger")
          ''#Use GlobalDiagnosticContext in 2.0, GDC in pre-2.0
          NLog.GlobalDiagnosticsContext.Set("appName", _appName)
          NLog.GlobalDiagnosticsContext.Set("fileVersion", _fileVersion)
          NLog.GlobalDiagnosticsContext.Set("logId", 0)
          headerLogger.Info("")
      End If
  End Sub
  </code></pre>
  
  <p>The idea is that if the file does not exist, then the file is generated by calls to the NLog logger instance, at which point the file is created and the specified header info is inserted.  The method works fine from the application itself, however I have a simple NUnit test which implements a test method to verify that the file is created and populated as expected.  When I step through with the debugger, I find that '_logPath' is set to:</p>
  
  <p>D:\Documents and Settings\TE602510\Local Settings\Temp\nunit20\ShadowCopyCache\4288_634286300896838506\Tests_-1937845265\assembly\dl3\7cdfe61a\aa18c98d_f0a1cb01\logs\2010-12-22.log</p>
  
  <p>Unfortunately, despite the fact that the file DOES exist, the call to File.Exists returns false.  From earlier viewing of the config path the above path would appear to be correct for these NUnit tests.  Does anybody have a clue what is happening here and what I need to do to get the desired result?  The pathname to the log file as per the XP file system is:</p>
  
  <p>D:\Documents and Settings\TE602510\My Documents_VSSWorkArea\PsalertsIp\Tests\bin\Debug\logs</p>
  
  <p>Kind Regards</p>
  
  <p>Paul J.</p>