解决方法
其次,您不仅需要字节数.您将需要与文件关联的元数据.对于下面的代码片段,我将所有的元数据放在一个单独的类(本地实例名为“file”)中.然后,只要使用此代码段,一旦您拥有所需的数据:
var stream = fhelp.DownloadFile(fileId);
var ms = new MemoryStream();
stream.CopyTo(ms);
ServiceLog.Info(string.Format("调用【下载文件】方法,处理结果:{0}", Convert.ToBase64String(ms.GetBuffer())));
var file = ms.GetBuffer();
Context.Response.Clear();
Context.Response.ClearHeaders();
Context.Response.ContentType = "application/octet-stream";
Context.Response.AddHeader("Content-Disposition", "attachment; filename=\"" + "uuuuu" + "\"");
Context.Response.AddHeader("Content-Length", file.Length.ToString());
Context.Response.OutputStream.Write(file,0,file.Length);//(file.Bytes, file.Bytes.Length)
Context.Response.Flush();
Context.Response.End();