我试图将程序文件复制到Windows 10启动文件夹,因此当用户打开计算机时,该程序也将启动。
然而,每次我关闭程序时,"错误"如果尝试失败,我会告诉它要做的消息弹出。
这是我的代码
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
感谢