Hi @HowardMontemurro-7208 , Welcome to Microsoft Q&A.
For c#, Httpclient has corresponding examples on the official website.
You can also refer to these two vb cases:HttpWebRequest to HttpClient post Request and VB.net POST method using HTTPclient
The following vb httpclient code is for reference only:
Private Async Sub DownloadFileFromFtp()
Dim ftpUrl As String = "ftp://ftps0.mywebsource.com/myload-source/myfilename.txt"
Dim userName As String = "MyUserName"
Dim password As String = "MyPassword"
Using httpClient As New HttpClient()
Dim credentials As New System.Net.NetworkCredential(userName, password)
httpClient.DefaultRequestHeaders.Authorization = New System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes($"{userName}:{password}")))
Dim response As HttpResponseMessage = Await httpClient.GetAsync(ftpUrl)
If response.IsSuccessStatusCode Then
Using fileStream As IO.FileStream = Await response.Content.ReadAsStreamAsync()
Using outputFileStream As IO.FileStream = IO.File.Create("path\to\save\downloaded\file\myfilename.txt")
Await fileStream.CopyToAsync(outputFileStream)
End Using
End Using
' File downloaded successfully.
MessageBox.Show("File downloaded successfully.")
Else
' Handle the case when file download fails.
MessageBox.Show($"File download failed. Status code: {response.StatusCode}")
End If
End Using
End Sub
Best Regards,
Jiale
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.