469,593 Members | 1,984 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,593 developers. It's quick & easy.

Save a zip file locally?

I dunno how save a file locally! How can I copy a file
(http://foo.com/foo.zip) to my local server
(http://mydomain.com/temp/foo.zip)?

I saw a sample in MS Quick Start but I can't manipulate it to work with for
example zip files.

WebRequest req = WebRequest.Create(txbFile.Text);

try {
WebResponse result = req.GetResponse();
Stream ReceiveStream = result.GetResponseStream();
if(true) {
StreamWriter writer = new StreamWriter(ResolvePath("temp.zip"));

Byte[] read = new Byte[512];
int bytes = ReceiveStream.Read(read, 0, 512);

// int i = ReceiveStream.ReadByte();
while (bytes > 0) {
writer.Write(bytes);
bytes = ReceiveStream.Read(read, 0, 512);
}
// while(i != -1){
// writer.Write(i);
// i = ReceiveStream.ReadByte();
// }
writer.Close();
lblResult.ForeColor = Color.Black;
lblResult.Text = "Operation Succeed!";
btnShow.Text = "Download File!";
btnShow.Enabled = true;
}
} catch(Exception _ex) {
lblResult.Text = _ex.ToString();
}

TIA
- Michael Rogers
Nov 17 '05 #1
0 1614

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by kieran | last post: by
4 posts views Thread by sunilj20 | last post: by
4 posts views Thread by Matt | last post: by
4 posts views Thread by teeBull | last post: by
2 posts views Thread by Adam | last post: by
6 posts views Thread by greg_e | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.