Tag: httpwebresponse

从url下载.xls文件

我试图从url下载一个xls文件: http : //www.site.com/ff/excel/file.aspx? deven =0 我正在使用此代码,但下载完成后,文件没有正确下载。 我怎样才能正确地下载这个文件? string remoteFilename="http://www.site.com/ff/excel/file.aspx?deven=0"; string localFilename = "D:\\1\\1.xls"; Stream remoteStream = null; Stream localStream = null; WebResponse response = null; try { // Create a request for the specified remote file name WebRequest request = WebRequest.Create(remoteFilename); if (request != null) { // Send the request to the server and […]

将WebResponse保存为服务器的Excel

我需要将内容types为“application / vnd.ms-excel”的响应保存为具有随机文件名的服务器。 我正在使用下面的代码通过屏幕抓取得到响应,我需要将其保存为excel到我的服务器path。 StreamWriter writer = new StreamWriter(webRequest.GetRequestStream()); writer.Write(postData); writer.Close(); try { responseReader = new StreamReader(webRequest.GetResponse().GetResponseStream()); //Save the response as Excel to the server string responseData = responseReader.ReadToEnd(); } catch { } 请build议将响应保存为excel到服务器path