473,799 Members | 3,224 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

downLoadFile Issue

I have a loop that loops through this sub. However, I recieve an
WebException error in my try statement. "An exception occurred during a
WebClient request." This message doesnt happen when I am only looping
throught the sub once, however when I process multiple records, I recieve
this error for every record after the first one.

And the images that is downloaded does show up for all records processed. So
everything works there is just an error, that says to the contrary.

TIA,

Steve Wofford
' Create a new WebClient instance.
Dim myWebClient As New System.Net.WebC lient
' Sets the default image directory
Dim checksSignature Uri As String = "http://68.106.74.63/rateQuest/images/"
' Sets the imagename used for both download and local file access
Dim checksSignature FileName As String = "checksSignatur e.jpg"
' Sets download resource
Dim checksSignature Resource As String = checksSignature Uri +
checksSignature FileName
' Sets the local resource for local app to access the downloaded file
Dim checksSignature LocalFile As String = "C:\" + checksSignature FileName
Try
' Downloads the file
myWebClient.Dow nloadFile(check sSignatureResou rce, checksSignature LocalFile)
Catch ex As System.Net.WebE xception
MsgBox("Unexpec ted Error occurred with Check Signature Image from URL: " &
ex.Message.ToSt ring())
' INSERT AN EXIT APPICATIION METHOD TO CLOST THE APP.
End Try
' Imports checksSignature .jpg 150px X 60px
Dim checksSignature As New Bitmap(checksSi gnatureLocalFil e)
xPos = leftMargin + 450
yPos = topMargin + 120
ev.Graphics.Dra wImage(checksSi gnature, xPos, yPos)
Nov 20 '05 #1
3 1871
Hi

Thanks for using Microsoft MSDN Managed Newsgroup.

Currently I am looking for somebody who could help you on it. We will reply
here with more information as soon as possible.
If you have any more concerns on it, please feel free to post here.
Thanks!

Best regards,

Gary Chang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------

Nov 20 '05 #2
Hi Steve,

First of all, I would like to confirm my understanding of your issue.
From your description, I understand that you wants to downloadfile using
WebClient and display them
in a loop and you get the "An exception occurred during a WebClient
request."
Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.

Based on my test, I can not reproduce the problem. Here is my test code,
you may have a try and let me know the result.
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
Dim str(4) As String
Dim i As Integer
'Put four file "Bluehills.jpg" , "Sunset.jpg ", "Waterlilies.jp g" and
"Winter.jpg " in the C:\Inetpub\wwwr oot
str(0) = "Bluehills. jpg"
str(1) = "Sunset.jpg "
str(2) = "Waterlilies.jp g"
str(3) = "Winter.jpg "
For i = 0 To 3
Dim myWebClient As New System.Net.WebC lient
'myWebClient.Cr edentials = CredentialCache .DefaultCredent ials
' Sets the default image directory
Dim checksSignature Uri As String = "http://localhost/"
' Sets the imagename used for both download and local file
access
Dim checksSignature FileName As String = str(i)
' Sets download resource
Dim checksSignature Resource As String = checksSignature Uri +
checksSignature FileName
' Sets the local resource for local app to access the
downloaded file
Dim checksSignature LocalFile As String = "c:\" +
checksSignature FileName
Try
' Downloads the file
myWebClient.Dow nloadFile(check sSignatureResou rce,
checksSignature LocalFile)
Catch ex As System.Net.WebE xception
Console.WriteLi ne("Unexpected Error occurred with Check
Signature Image from URL: " & ex.Message.ToSt ring())
' INSERT AN EXIT APPICATIION METHOD TO CLOST THE APP.
End Try
' Imports checksSignature .jpg 150px X 60px
Dim checksSignature As New Bitmap(checksSi gnatureLocalFil e)
'Use the CreateGraphics method to create a Graphics object.
Dim formGraphics As Graphics
formGraphics = Me.CreateGraphi cs
'Draw a rectangle on the form.
formGraphics.Dr awImage(checksS ignature, 0, 0)
System.Threadin g.Thread.Sleep( 1000)
Next
End Sub

Please Apply My Suggestion Above And Let Me Know If It Helps Resolve Your
Problem.
However, if the problem still persists, you may also simplifie your code as
long as it can reproduce the problem as post here.

Best regards,

Perter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #3
Thanks Peter,

I believe I solved the problem, your example provided a differant file name
per loop iteration. However mine stayed the same, and I believe it was due
to the fact that the download was trying to overwrite a file that already
existed, and causing an error. As soon as I put a
If counter = 0 The
DownloadFile
EndIf
Do rest of loop....

That is all I really changed, but the error didnt have anything to say about
a file protection error, but is working now and wanted to thank you.

Steve Wofford
www.IntraRELY.com

"Peter Huang" <v-******@online.m icrosoft.com> wrote in message
news:y0******** ******@cpmsftng xa07.phx.gbl...
Hi Steve,

First of all, I would like to confirm my understanding of your issue.
From your description, I understand that you wants to downloadfile using
WebClient and display them
in a loop and you get the "An exception occurred during a WebClient
request."
Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.

Based on my test, I can not reproduce the problem. Here is my test code,
you may have a try and let me know the result.
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
Dim str(4) As String
Dim i As Integer
'Put four file "Bluehills.jpg" , "Sunset.jpg ", "Waterlilies.jp g" and "Winter.jpg " in the C:\Inetpub\wwwr oot
str(0) = "Bluehills. jpg"
str(1) = "Sunset.jpg "
str(2) = "Waterlilies.jp g"
str(3) = "Winter.jpg "
For i = 0 To 3
Dim myWebClient As New System.Net.WebC lient
'myWebClient.Cr edentials = CredentialCache .DefaultCredent ials
' Sets the default image directory
Dim checksSignature Uri As String = "http://localhost/"
' Sets the imagename used for both download and local file
access
Dim checksSignature FileName As String = str(i)
' Sets download resource
Dim checksSignature Resource As String = checksSignature Uri +
checksSignature FileName
' Sets the local resource for local app to access the
downloaded file
Dim checksSignature LocalFile As String = "c:\" +
checksSignature FileName
Try
' Downloads the file
myWebClient.Dow nloadFile(check sSignatureResou rce,
checksSignature LocalFile)
Catch ex As System.Net.WebE xception
Console.WriteLi ne("Unexpected Error occurred with Check
Signature Image from URL: " & ex.Message.ToSt ring())
' INSERT AN EXIT APPICATIION METHOD TO CLOST THE APP.
End Try
' Imports checksSignature .jpg 150px X 60px
Dim checksSignature As New Bitmap(checksSi gnatureLocalFil e)
'Use the CreateGraphics method to create a Graphics object.
Dim formGraphics As Graphics
formGraphics = Me.CreateGraphi cs
'Draw a rectangle on the form.
formGraphics.Dr awImage(checksS ignature, 0, 0)
System.Threadin g.Thread.Sleep( 1000)
Next
End Sub

Please Apply My Suggestion Above And Let Me Know If It Helps Resolve Your
Problem.
However, if the problem still persists, you may also simplifie your code as long as it can reproduce the problem as post here.

Best regards,

Perter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #4

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

Similar topics

1
4277
by: James Write | last post by:
Hi, I am using the webclient.downloadfile() method to download a file from a remote web server to the local harddrive. public CopyFile(string sSrcPath, string sDestPath) { WebClient oClient = new WebClient(); oClient.DownloadFile(sSrcPath,sDestPath); }
6
13305
by: A.M-SG | last post by:
Hi, I have an aspx page at the web server that provides PDF documents for smart client applications. Here is the code in aspx page that defines content type: Response.ContentType = "application/octet-stream"; Response.AppendHeader("Content-Disposition", "attachment;filename=" + fileID.ToString() + ".pdf");
1
4805
by: Cheri Elkin | last post by:
I recieve the following error when attempting to download a file from our web server to be placed on our hard drive. Any clues as to why I would get this error? By the way, the directory already exists on the hard drive ("c"). System.Net.WebException: An exception occurred during a WebClient request. ---> System.IO.DirectoryNotFoundException: Could not find a part of the path "C:\Essex\Download\POLEXPT1.DT1". at...
8
9026
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...
2
4183
by: cindy.fisher | last post by:
I am using DownloadFile() on a C# web app to download a file to a client. When I set the WebClient credentials to the DefaultCredentials, I get a 401 Unauthorized exception. WebClient myWC = new WebClient(); myWC.Credentials = CredentialCache.DefaultCredentials; myWC.DownloadFile(myRemoteUri, myFile); However, when I set the credentials using a username and password it works.
1
2933
by: peter.rietmann | last post by:
I have been suddenly having a performance problem downloading images from one server (productive) to another (productive) using the following code .. WebClient webClient = new WebClient(); try { webClient.DownloadFile(sourceUrlFilename, destinationFilename); } catch (Exception ex)
6
1318
by: Morten Snedker | last post by:
I have this Class: Imports System.Net Public Class DownloadFile Private _webClt As WebClient Private _url As String Private _file As String Sub New(ByVal urlSource As String, ByVal fileDestination As String)
2
3258
by: Lila Godel | last post by:
I am having a problem with the download of web pages via the WebClient.DownloadFile function in the specialized VB.Net 2003 I.E. plug-in I am designing to speed up the work on my latest project. When I edit the web pages in notepad I see a square wherever I normally see a carriage return and a line feed when viewing the source in I.E. How can I make the web pages come down readable so I can easily make my two manual deletions...
8
9530
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?
0
9685
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9538
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
10470
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...
0
10247
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7561
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...
0
6803
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5459
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4135
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
3751
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.