Open a text file with vb.net , and if it exists delete that file <p>I am writing code for a windows application using vb.net. I want to open a text file under <code>c:\</code>. If the file already exists I want to delete that file.</p> <pre><code>my code ------- Dim file As String = "C:\test.txt" If System.IO.File.Exists(file) Then file.Remove(file) Else System.Diagnostics.Process.Start(file) End If </code></pre> <p>I am getting the following error when I try to open that file.</p> <pre><code>error ----- The system cannot find the file specified </code></pre>