title: Copying a file to the startup folder Windows 10 VB.net
body: <p>I'm trying to copy a program file to the windows 10 start up folder so when the user turns their computer on this program will also start up.</p>
  
  <p>However every time i close the program the "Error" message pops up that i have told it to do if the try fails.</p>
  
  <p>here is my code</p>
  
  <pre><code>Private Sub Form1_Closing(sender As Object, e As CancelEventArgs) Handles Me.Closing
      Dim Location As String = "C:\Users\Andrew\AppData\Local\Apps\2.0\BK94W342.09X\Y2ZQNR9E.C06\netw..tion_9d5f77662cbecf48_0001.0000_becfdf7c1bd783a8\Network Tester.exe"
      Dim Destination As String = "C:\Users\Andrew\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup"
  
      Try
          My.Computer.FileSystem.CreateDirectory(Destination)
          If My.Computer.FileSystem.CurrentDirectory(Location.Contains("Network Tester")) Then
              ''nothing
          ElseIf Not My.Computer.FileSystem.CurrentDirectory(Location.Contains("Network Tester")) Then
              My.Computer.FileSystem.CopyFile(Location, Destination)
          End If
      Catch ex As Exception
          MessageBox.Show("Error")
      End Try
  
  End Sub
  </code></pre>
  
  <p>thanks</p>