title: Create a text file and write to it
body: <p>I want to create a text file and write some text into this file, but my code cannot create the text file.</p>
  
  <p>Error message: </p>
  
  <pre><code>    UnauthorizedAccessExcepion was unhandled by user code
   Access to the path 'c:\save.txt' is denied.
  </code></pre>
  
  <p>My code:</p>
  
  <pre><code> Dim fileLoc As String = "c:\save.txt"
                      Dim fs As FileStream = Nothing
                      If (Not File.Exists(fileLoc)) Then
                          fs = File.Create(fileLoc)
                          Using fs
  
                          End Using
                      End If
                      If File.Exists(fileLoc) Then
                          Using sw As StreamWriter = New StreamWriter(fileLoc)
                              a = "Test: " + TextBox1.Text
                              c = "=============================================="
                              sw.Write(a)
                              sw.Write(c)
                          End Using
                      End If
  </code></pre>