473,770 Members | 1,629 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_Serve r/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?
'************Co de starts here
Imports System.IO
Imports System.Net
Imports System.Text

Module Module1
Sub Main()
Dim fullfiledownloa d 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"

fullfiledownloa d = fileurl & filedownload
filefullpath = filepath & newfilename

Dim wc As New WebClient
Dim myCredentials As New NetworkCredenti al(userid,
userpassword)
wc.Credentials = myCredentials
wc.DownloadFile (fullfiledownlo ad, filefullpath)
End Sub
End Module
Sep 25 '06 #1
1 9876
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***@discussi ons.microsoft.c oma écrit dans le message de news:
8D************* *************** **...icrosof t.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_Serve r/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?
'************Co de starts here
Imports System.IO
Imports System.Net
Imports System.Text

Module Module1
Sub Main()
Dim fullfiledownloa d 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"

fullfiledownloa d = fileurl & filedownload
filefullpath = filepath & newfilename

Dim wc As New WebClient
Dim myCredentials As New NetworkCredenti al(userid,
userpassword)
wc.Credentials = myCredentials
wc.DownloadFile (fullfiledownlo ad, 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
4088
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 System.Net.WebClient web.Headers.Add("Content-Type", "application/x-www-form-urlencoded")
8
9025
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. The portion of the code that pulls from the drive works great, but when the http address is active it changes the originating path to my C:\Windows\System32 folder instead of the proper path. I keep the path as a field on my form so I am certain...
0
1834
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 :-)) to receive and send files from within the app itself. Now the server I connect to (IIS 5, W2K Svr+SP4) from 1st Jan on will allow just http/https connection, so I can no longer use FTP. I've thought to use System.Net.WebClient class and...
4
14286
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
11037
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 NetworkCredential();
0
1302
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 file is exactly the same as the source file? For example, when we try to download some big files from the internet e.g. Win XP - service pack 2, the IE download windows may sometime report download completed and terminate the download process, but...
8
9523
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 client. What am I doing wrong?
6
4926
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 and the file is copied from the server to the server, rather than from the web client to the server. Please help!!!
0
2851
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 throws a 407 proxy authentication required error. My question is that since I do not know whether the users are going to download a file thru a proxy, is there a way in C# to specify a general way of coding to handle proxy and non-proxy users? ...
0
9432
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10232
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10008
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9873
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8891
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7420
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
3974
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3578
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2822
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.