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.Crea te(txbFile.Text );
try {
WebResponse result = req.GetResponse ();
Stream ReceiveStream = result.GetRespo nseStream();
if(true) {
StreamWriter writer = new StreamWriter(Re solvePath("temp .zip"));
Byte[] read = new Byte[512];
int bytes = ReceiveStream.R ead(read, 0, 512);
// int i = ReceiveStream.R eadByte();
while (bytes > 0) {
writer.Write(by tes);
bytes = ReceiveStream.R ead(read, 0, 512);
}
// while(i != -1){
// writer.Write(i) ;
// i = ReceiveStream.R eadByte();
// }
writer.Close();
lblResult.ForeC olor = 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.Crea te(txbFile.Text );
try {
WebResponse result = req.GetResponse ();
Stream ReceiveStream = result.GetRespo nseStream();
if(true) {
StreamWriter writer = new StreamWriter(Re solvePath("temp .zip"));
Byte[] read = new Byte[512];
int bytes = ReceiveStream.R ead(read, 0, 512);
// int i = ReceiveStream.R eadByte();
while (bytes > 0) {
writer.Write(by tes);
bytes = ReceiveStream.R ead(read, 0, 512);
}
// while(i != -1){
// writer.Write(i) ;
// i = ReceiveStream.R eadByte();
// }
writer.Close();
lblResult.ForeC olor = Color.Black;
lblResult.Text = "Operation Succeed!";
btnShow.Text = "Download File!";
btnShow.Enabled = true;
}
} catch(Exception _ex) {
lblResult.Text = _ex.ToString();
}
TIA
- Michael Rogers