|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
VB.NET 2005 WebClient file download via HTTPSMy goal is to create a executable to download files from a HTTPS server. I have to pass the credentials to the https server. The code below works fine on our IIS server configured for https but when I connect to a remote server running "IBM_HTTP_Server/2.0.47.1-PK29827 Apache/2.0.47 (Win32) Server" The error I get is Unauthorized... My Error: The remote server returned an error: (401) Unauthorized. How can I fix this so it works on any https server... or is there a better way to do this? '************Code starts here Imports System.IO Imports System.Net Imports System.Text Module Module1 Sub Main() Dim fullfiledownload As String Dim filefullpath As String Dim fileurl As String = "https://someserver/" Dim filedownload As String = "fcs_hail_data_06.txt" Dim newfilename As String = "Igotit.TXT" Dim filepath As String = "C:\" Dim userid As String = "userid" Dim userpassword As String = "password" fullfiledownload = fileurl & filedownload filefullpath = filepath & newfilename Dim wc As New WebClient Dim myCredentials As New NetworkCredential(userid, userpassword) wc.Credentials = myCredentials wc.DownloadFile(fullfiledownload, filefullpath) End Sub End Module Does it work "by hand" with these credentials ? It would likely allows to
see if the credentials and/or the file permission are not correct or if this is a problem with the code... -- "Chad T" <Ch***@discussions.microsoft.com> a écrit dans le message de news: 8D01600A-5214-4704-AD4A-3B5ACDDC1***@microsoft.com...Show quoteHide quote >I am very new to VB.Net (most of my experience is with vbscript) > My goal is to create a executable to download files from a HTTPS server. > I have to pass the credentials to the https server. > > The code below works fine on our IIS server configured for https but when > I > connect to a remote server running "IBM_HTTP_Server/2.0.47.1-PK29827 > Apache/2.0.47 (Win32) Server" The error I get is Unauthorized... > > My Error: The remote server returned an error: (401) Unauthorized. > > How can I fix this so it works on any https server... or is there a better > way to do this? > > > '************Code starts here > Imports System.IO > Imports System.Net > Imports System.Text > > Module Module1 > Sub Main() > Dim fullfiledownload As String > Dim filefullpath As String > > Dim fileurl As String = "https://someserver/" > Dim filedownload As String = "fcs_hail_data_06.txt" > Dim newfilename As String = "Igotit.TXT" > Dim filepath As String = "C:\" > Dim userid As String = "userid" > Dim userpassword As String = "password" > > fullfiledownload = fileurl & filedownload > filefullpath = filepath & newfilename > > Dim wc As New WebClient > Dim myCredentials As New NetworkCredential(userid, > userpassword) > wc.Credentials = myCredentials > wc.DownloadFile(fullfiledownload, filefullpath) > End Sub > End Module
Copy Directory
Windows Service, timer doesn't tick split container Help with some research multi line list box Run Adobe Acrobat from within VB.Net app How to close the parent and all child forms together at once when click on parent window's close but Best sites for source code examples? Getting A generic error occurred in GDI+ message ComboBox-binding an ein gefiltertes Dataset.Table-Object |
|||||||||||||||||||||||