2

GZip について質問があります。

.Net で作成された動的フォームがいくつかあります。ここで、フォーム データ (html + Java スクリプト) を gzip してデータベースに保存したいと考えています。そのため、ユーザーがフォーム (JQuery Ajax) を要求すると、gzip されたバージョンを提供できます。私は GZipStream. で試しましたが、うまくいきませんでした。

何かご意見は??

System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();

    byte[] byteArray = new byte[value.Length];
    byteArray = encoding.GetBytes(value);

    //Prepare for compress
    System.IO.MemoryStream ms = new System.IO.MemoryStream();
    System.IO.Compression.GZipStream sw = new System.IO.Compression.GZipStream(ms, System.IO.Compression.CompressionMode.Compress, true);

    //Compress
    sw.Write(byteArray, 0, byteArray.Length);
    //Close, DO NOT FLUSH cause bytes will go missing...
    sw.Close();

    System.Text.StringBuilder sB = new System.Text.StringBuilder();
    byte[] finalData = ms.ToArray();
    ms.Close();
    sw.Dispose();
    ms.Dispose();
    sB.Append(encoding.GetString(finalData));

    //Response.ClearContent();
    //Response.OutputStream.Write(ms.ToArray(), 0, ms.ToArray().Length);

    return sB.ToString();

ありがとう、シラス

4

0 に答える 0