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

WebClient Question

Hi there,

Can anyone tell me why this code appears to be throwing a WebException, and
also why the files are still downloading
try
{
imageData = webClient.DownloadData(total);
MemoryStream ms = new MemoryStream(imageData);
Bitmap b = new Bitmap(ms);
b.Save(@"C:\temp\IMAGE", ImageFormat.Tiff);
}
catch(Exception ex)
{
MessageBox.Show(ex.StackTrace);
}

the file IMAGE.tif is still saved, and it is also the correct file, im
gettin the following error

the remote server has returned an error: (404) Not Found
Nov 17 '05 #1
2 2306
Thaynann <Th******@discussions.microsoft.com> wrote:
Can anyone tell me why this code appears to be throwing a WebException, and
also why the files are still downloading
try
{
imageData = webClient.DownloadData(total);
MemoryStream ms = new MemoryStream(imageData);
Bitmap b = new Bitmap(ms);
b.Save(@"C:\temp\IMAGE", ImageFormat.Tiff);
}
catch(Exception ex)
{
MessageBox.Show(ex.StackTrace);
}

the file IMAGE.tif is still saved, and it is also the correct file, im
gettin the following error

the remote server has returned an error: (404) Not Found


It seems very unlikely to me that your diagnosis is correct. Could you
post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

Note that you should dispose of the bitmap after you're finished with
it (eg with a "using" statement).

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #2
Hi,
Sound very difficult to believe, you see, the only method that can throw
that exception is DownloadData , if it does so you don't get a return value

What you get in your stacktrace?

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Thaynann" <Th******@discussions.microsoft.com> wrote in message
news:F7**********************************@microsof t.com...
Hi there,

Can anyone tell me why this code appears to be throwing a WebException,
and
also why the files are still downloading
try
{
imageData = webClient.DownloadData(total);
MemoryStream ms = new MemoryStream(imageData);
Bitmap b = new Bitmap(ms);
b.Save(@"C:\temp\IMAGE", ImageFormat.Tiff);
}
catch(Exception ex)
{
MessageBox.Show(ex.StackTrace);
}

the file IMAGE.tif is still saved, and it is also the correct file, im
gettin the following error

the remote server has returned an error: (404) Not Found

Nov 17 '05 #3

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

Similar topics

5
by: Seymen Ertas | last post by:
Hi, I don't know if this is the correct place to post this but i am having a little problem with the OpenRead function of the WebClient. Below is the code i am trying to get it to work: ...
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 =...
0
by: belfast neil | last post by:
Hey guys, I've seen alot of questions out there about webclient.uploadfile, my question is slightly different.......... I have a rich client app and I want to upload files to a server....
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 :-))...
1
by: Deepson Thomas | last post by:
Hi, Iam trying to use WebClient class under system.net namespace to download files from internet via http. For that iam using DownloadFile method. But when ever iam trying to download any file...
1
by: Chris Dunaway | last post by:
I am using the following code to test an .aspx page which has no presentation and only a handler for the Page_Load event. I am using this code to POST the contents of an .xml file to the .aspx...
3
by: Chip | last post by:
Hi, How do I add a required cookie to my WebClient.DownloadFile() request? Chip
1
by: Mad Scientist Jr | last post by:
For some reason I can't get a WebClient to access an outside URL from behind our firewall. The code works when it runs outside the firewall. I turned on windows authentication in the web.config...
1
by: Frank Rizzo | last post by:
My app utilizes the WebClient class to get files via FTP and to interrogate pages via HTTP. However, some sites that the software is being deployed to does not have always on connections. So I am...
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
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
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...
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
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...

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.