リボンにボタンを実装して複数のファイルをzip形式でダウンロードするSharepointのアプリケーションを作成しています...
すべてがうまくいき、すべてがうまくいきます...しかし、ChromeまたはFirefoxでzipをダウンロードしようとすると、何も起こりません。
私のコードはこれです:
private void WriteStreamToResponse(MemoryStream ms)
{
if (ms.Length > 0)
{
string filename = DateTime.Now.ToFileTime().ToString() + ".zip";
Response.Clear();
Response.ClearHeaders();
Response.ClearContent();
Response.ContentType = "application/zip"; //also tried application/octect and application/x-zip-compressed
Response.AddHeader("Content-Length", ms.Length.ToString());
Response.AddHeader("Content-Disposition", "attachment; filename=" + filename);
byte[] buffer = new byte[65536];
ms.Position = 0;
int num;
do
{
num = ms.Read(buffer, 0, buffer.Length);
Response.OutputStream.Write(buffer, 0, num);
}
while (num > 0);
Response.Flush();
}
}