TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Mai Hu Na
NA
86
133.2k
Download file using Webclient shows Wrong Data
Jul 15 2013 3:58 AM
hi Guyes,
i used following code to download file from secured site but file created on folder @"C:\Downloads\Filename" show HTML tags like This
<HTML>
<HEAD><LINK rel="stylesheet" type="text/css" name="defaultstyle" href="/cehttp/html/style.css">
<TITLE>Servlet Response Message</TITLE></HEAD>
<BODY>
<H2 align=center><H2>
<HR>
You are not logged on. Please logon first.
<HR>
</BODY></HTML>
then Actual File content.
try
{
WebClient client = new WebClient();
client.Credentials = new System.Net.NetworkCredential("username", "password");
byte[] pageData = client.DownloadData("url");
string pageHtml = Encoding.ASCII.GetString(pageData);
Console.WriteLine(pageHtml);
client.DownloadFile("url", @"C:\Downloads\071213.ACCT");
}
catch (WebException webEx)
{
Console.WriteLine(webEx.ToString());
if (webEx.Status == WebExceptionStatus.ConnectFailure)
{
Console.WriteLine("Are you behind a firewall? If so, go through the proxy server.");
}
}
Reply
Answers (
1
)
c# windows chat application
VS Lightswitch