M
Michael Rogers
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
(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