I'm downloading a file through my software and it completes the first time. But the second time it fails if I save it to the same directory. It overwrites the file, but refuses to download. If I save it to another directory it completes, but then I have to save it to yet another directory, or I can use the same directory as the original with success. I would like to save this file in the same directory every time with the same name, otherwise my program won't locate this file if needed to be run. any help please
My Code:
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