title: Visual Basic: Checking if file exists, if not, create the file
body: <p>This is the code. It checks if the file in path exists, if not, it creates the file. I'm getting this error message all the time and I don't know why. Maybe I should close the System.IO.Directory.Exists? If yes, how do I do that? Just so you know, I'm creating a text file.</p>
  
  <p><strong>The code</strong></p>
  
  <pre><code>If Not (System.IO.Directory.Exists(path)) Then
          Dim fs3 As FileStream = File.Create(path)
      End If
  </code></pre>
  
  <p><strong>This is the error message I get:</strong></p>
  
  <p>Process can't use the file (path) because some other process is using this file at the moment.</p>