473,395 Members | 1,658 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

VB.NET 2005 WebClient file download via HTTPS

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
Sep 25 '06 #1
1 9832
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.coma écrit dans le message de news:
8D**********************************@microsoft.com...
>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

Sep 25 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Kumar | last post by:
Hi all, I have the following code which uses WebClient.UploadValues myNameValueCollection.Add("Name", name) myNameValueCollection.Add("Age", age) .............. ............. Dim web As New...
8
by: DEWright_CA | last post by:
Why does WebClient.DownloadFile loose my completed path? Ok, I have a function in my app then when my button is clicked it checks to see if the files come from a local drive or a http address....
0
by: Saverio Tedeschi | last post by:
Hi all gurus, forgive me if I submit a 2nd post, but I'm no more able to see my question. So: I wrote an Win app with embedded FTP client (well, made some cut and paste from others' projects :-))...
4
by: gavkel | last post by:
Can anyone get this to work? All Im getting is the login html being downloaded. Would appreciate any help - my heads hurts Thanks Gav
3
by: df | last post by:
Hi, I'm trying to download the web page source code from a HTTPS URL, my code is as follows: Code: System.Net.WebClient WC = new System.Net.WebClient(); NetworkCredential Cred = new...
0
by: makinha | last post by:
Hello All, I can use WebClient.DownloadFile Method to download target file from the website, like WebClient.DownloadFile("http://www.abc.com/a.pdf", "D:\a.pdf") but how can I verify the...
8
by: =?Utf-8?B?UnVpIE9saXZlaXJh?= | last post by:
WebClient.DownloadFile I am using the WebClient.DownloadFile function to download a file from server to a local client. When I execute the below code, file is created in server and not in...
6
by: =?Utf-8?B?U2NvdHQgVHJpY2s=?= | last post by:
I followed the instructions from MSDN for Webclient UploadFile and I get an error: Could not find file 'C:\testfile.xls'. If I add the file (c:\testfile.xls) to the server I do not get the error...
0
by: malkin | last post by:
Hi all, I have an external application that calls WebClient to download a file from our server. It runs fine without any proxy server involved. However, once there is a proxy server layer, it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.