title: Saving Files to user Computer in VB.Net
body: <p>I have look for days, with no luck.</p>
  
  <p>Can anyone tell me how to save files in VB.Net to any computer? There are lost of articles, but those only tell you about saving to your own computer by giving folder access, not a random user's computer.</p>
  
  <p>You can see my example here <a href="http://hanontest.com/POShellCreator.aspx" rel="nofollow">http://hanontest.com/POShellCreator.aspx</a> (You have to enter text into task code, project id and notes field, then click create. Then click export, you will see the error.)</p>
  
  <p>I can go to a local Pizza shop website and download a menu pdf, I know its possible.</p>
  
  <p>In my example it saves when you click the button, I would like a save as dialog if anyone knows how to do that as well.</p>
  
  <p>Here is the save string:</p>
  
  <pre><code>  Dim regDate As Date = Date.Now()
          Dim strDate As String = regDate.ToString(".yyyy\.MM\.dd")
          TextBox5.Text = "c:\temp\" &amp; Vendor &amp; "&amp;" &amp; Vendor2 &amp; "&amp;" &amp; Vendor3 &amp; "&amp;" &amp; Vendor4 &amp; TaskEmpty &amp; strDate &amp; ".csv"
  </code></pre>
  
  <p>Here is how I am saving:</p>
  
  <pre><code> Public Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
  
      'Define Path to save file.
      Dim path As String = TextBox5.Text
  
      ' Create or overwrite the file. 
      Dim fs As FileStream = File.Create(path)
  
      ' Add text to the file. 
      Dim info As Byte() = New UTF8Encoding(True).GetBytes(TextBox3.Text)
      fs.Write(info, 0, info.Length)
      fs.Close()
  End Sub
  </code></pre>