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
rick
NA
5
0
Downloading zip files.
Jun 1 2006 9:50 AM
Hey guys,
Ive been having a problem downloading files through a proxy server. it worked fine while i was downloading small test files (zip files to be exact < 5kb) but when i use actual files, they are always corrupt on the client side, but when you open the zip file there are never more than 2 files present and they are corrupt as well. any help would be greatly appreciated.
Thanks,
here is
a before and after screen shot
of the zip files, if that helps, and the following is a code snippit.
public void BeginDownload(){
WebProxy
proxy
=
new
WebProxy
(
ServPath,
true
);
proxy
.
Credentials
=
new
NetworkCredential
(
UserName,
Pass);
WebRequest
request
=
WebRequest
.
Create(
ServPath + FileName);
request
.
Proxy
=
proxy;
// Send the 'HttpWebRequest' and wait for response.
HttpWebResponse
response
=
(
HttpWebResponse
)request
.
GetResponse();
System
.
IO
.
Stream
stream
=
response
.
GetResponseStream();
FileStream
writeStream
=
new
FileStream
(Download
Path + FileName,
FileMode
.
Create,
FileAccess
.
Write);
ReadWriteStream(stream, writeStream, response
.
ContentLength);
response
.
Close();
}
private
void
ReadWriteStream(
Stream
readStream,
Stream
writeStream,
long
lLength)
{
int
Length
=
Convert
.
ToInt32(lLength);
Byte
[] buffer
=
new
Byte
[Length
+
(
100
-
Length
%
100
)
+
5
];
int
numBytesToRead
=
Length;
int
numBytesRead
=
0
;
while
(numBytesToRead
>
0
)
{
int
n;
n
=
readStream
.
Read(buffer, numBytesRead, numBytesToRead);
WriteStream
.
Write(buffer, numBytesRead, numBytesToRead);
numBytesRead
+=
n;
numBytesToRead
-=
n;
}
readStream
.
Close();
writeStream
.
Close();
}
Reply
Answers (
3
)
textbox enter
'HttpContext' does not exist in the class or...