Home > Net > How to download the file to the local
How to download the file to the local
Time:05-13
I excel in the server folder down a excel file, and then I want to download to my local hard disk, but I used the following method to download is no problem, but D plate are downloaded to the server, rather than my local, how can I get to download to a local, I tried the following two methods are not Method 1: http://HttpWebRequest request=WebRequest. Create (" * * * * * * */Home/Excel/line data. XLSX ") as HttpWebRequest. //send the request and obtain the corresponding response data As HttpWebResponse HttpWebResponse response=request. The method GetResponse (); //until the request. The method GetResponse () program to start sending a Post request to the target web page Stream responseStream=response. GetResponseStream ();
//create a local file stream Stream, Stream=new FileStream (" D: \ \ data. XLSX, FileMode. Create);
Byte [] bArr=new byte [1024]. Int size=responseStream. Read (bArr, 0, (int) bArr. Length); While (size & gt; 0) { Stream. Write (bArr, 0, size); Size=responseStream. Read (bArr, 0, (int) bArr. Length); } Stream. The Close (); ResponseStream. Close ();