我正在通过我的软件下载一个文件,第一次下载就完成了。但是第二次如果我将它保存到同一个目录,它就会失败。它会覆盖文件,但拒绝下载。如果我将它保存到另一个目录,它会完成,但随后我必须将它保存到另一个目录,或者我可以使用与原始目录相同的目录来成功下载。我希望每次都用相同的名称将此文件保存在同一个目录中,否则我的程序在需要运行时将找不到此文件。请帮忙
我的代码:
Private Sub Updt_Click(sender As Object, e As EventArgs) Handles Updt.Click
Dim VlcGetUrl64 As String = " http://update.videolan.org/vlc/status-win-x64" 'Gets new update url
Dim Vlc64Dir As String = "Software\x64\vlc.exe" 'Save file as
Dim VlcSaveUrl As String = "Software\x64\updateUrl.txt" 'Save file url
Try
Using client = New WebClient()
Using stream = client.OpenRead("http://www.google.com")
If System.Environment.Is64BitOperatingSystem = True Then
Try
' Make a WebClient.
Dim web_client As WebClient = New WebClient
' Download the file.
web_client.DownloadFile(VlcGetUrl, VlcSaveUrl)
Dim Counter As String = System.IO.File.ReadAllLines(VlcSaveUrl)(1) 'Read URL in updateUrl.txt
web_client.DownloadFile(Counter, Vlc64Dir)
Form2.RichTextBox1.AppendText(ChrW(&H2713))
Catch ex As Exception
TextBox1.Text = "Done"
End Try
End If
End Using
End Using
Catch ex As Exception
TextBox1.Text = "Error"
End Try
End Sub