473,398 Members | 2,389 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,398 software developers and data experts.

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.WebClient
' Sets the default image directory
Dim checksSignatureUri As String = "http://68.106.74.63/rateQuest/images/"
' Sets the imagename used for both download and local file access
Dim checksSignatureFileName As String = "checksSignature.jpg"
' Sets download resource
Dim checksSignatureResource As String = checksSignatureUri +
checksSignatureFileName
' Sets the local resource for local app to access the downloaded file
Dim checksSignatureLocalFile As String = "C:\" + checksSignatureFileName
Try
' Downloads the file
myWebClient.DownloadFile(checksSignatureResource, checksSignatureLocalFile)
Catch ex As System.Net.WebException
MsgBox("Unexpected Error occurred with Check Signature Image from URL: " &
ex.Message.ToString())
' INSERT AN EXIT APPICATIION METHOD TO CLOST THE APP.
End Try
' Imports checksSignature.jpg 150px X 60px
Dim checksSignature As New Bitmap(checksSignatureLocalFile)
xPos = leftMargin + 450
yPos = topMargin + 120
ev.Graphics.DrawImage(checksSignature, xPos, yPos)
Nov 20 '05 #1
3 1850
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(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim str(4) As String
Dim i As Integer
'Put four file "Bluehills.jpg", "Sunset.jpg", "Waterlilies.jpg" and
"Winter.jpg" in the C:\Inetpub\wwwroot
str(0) = "Bluehills.jpg"
str(1) = "Sunset.jpg"
str(2) = "Waterlilies.jpg"
str(3) = "Winter.jpg"
For i = 0 To 3
Dim myWebClient As New System.Net.WebClient
'myWebClient.Credentials = CredentialCache.DefaultCredentials
' Sets the default image directory
Dim checksSignatureUri As String = "http://localhost/"
' Sets the imagename used for both download and local file
access
Dim checksSignatureFileName As String = str(i)
' Sets download resource
Dim checksSignatureResource As String = checksSignatureUri +
checksSignatureFileName
' Sets the local resource for local app to access the
downloaded file
Dim checksSignatureLocalFile As String = "c:\" +
checksSignatureFileName
Try
' Downloads the file
myWebClient.DownloadFile(checksSignatureResource,
checksSignatureLocalFile)
Catch ex As System.Net.WebException
Console.WriteLine("Unexpected Error occurred with Check
Signature Image from URL: " & ex.Message.ToString())
' INSERT AN EXIT APPICATIION METHOD TO CLOST THE APP.
End Try
' Imports checksSignature.jpg 150px X 60px
Dim checksSignature As New Bitmap(checksSignatureLocalFile)
'Use the CreateGraphics method to create a Graphics object.
Dim formGraphics As Graphics
formGraphics = Me.CreateGraphics
'Draw a rectangle on the form.
formGraphics.DrawImage(checksSignature, 0, 0)
System.Threading.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.microsoft.com> wrote in message
news:y0**************@cpmsftngxa07.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(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim str(4) As String
Dim i As Integer
'Put four file "Bluehills.jpg", "Sunset.jpg", "Waterlilies.jpg" and "Winter.jpg" in the C:\Inetpub\wwwroot
str(0) = "Bluehills.jpg"
str(1) = "Sunset.jpg"
str(2) = "Waterlilies.jpg"
str(3) = "Winter.jpg"
For i = 0 To 3
Dim myWebClient As New System.Net.WebClient
'myWebClient.Credentials = CredentialCache.DefaultCredentials
' Sets the default image directory
Dim checksSignatureUri As String = "http://localhost/"
' Sets the imagename used for both download and local file
access
Dim checksSignatureFileName As String = str(i)
' Sets download resource
Dim checksSignatureResource As String = checksSignatureUri +
checksSignatureFileName
' Sets the local resource for local app to access the
downloaded file
Dim checksSignatureLocalFile As String = "c:\" +
checksSignatureFileName
Try
' Downloads the file
myWebClient.DownloadFile(checksSignatureResource,
checksSignatureLocalFile)
Catch ex As System.Net.WebException
Console.WriteLine("Unexpected Error occurred with Check
Signature Image from URL: " & ex.Message.ToString())
' INSERT AN EXIT APPICATIION METHOD TO CLOST THE APP.
End Try
' Imports checksSignature.jpg 150px X 60px
Dim checksSignature As New Bitmap(checksSignatureLocalFile)
'Use the CreateGraphics method to create a Graphics object.
Dim formGraphics As Graphics
formGraphics = Me.CreateGraphics
'Draw a rectangle on the form.
formGraphics.DrawImage(checksSignature, 0, 0)
System.Threading.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
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...
6
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 =...
1
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...
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....
2
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...
1
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...
6
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...
2
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. ...
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...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...
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.