0

I would like to know if it is possible to gzip a powerpoint file. the reason for me asking this question is because all of the article which I have found are gzipping a .txt and would like to know if its possible to gzip a .pptx.. through the use of c#.. the code below is what i am using

static void Main()
    {
    try
    {
        string anyString = File.ReadAllText("presentation.pptx");

        CompressStringToFile("new.gz", anyString);
    }
    catch
    {
        // Couldn't compress.
    }
    }

    public static void CompressStringToFile(string fileName, string value)
    {
    // A.
    // Write string to temporary file.
    string temp = Path.GetTempFileName();
    File.WriteAllText(temp, value);

    // B.
    // Read file into byte array buffer.
    byte[] b;
    using (FileStream f = new FileStream(temp, FileMode.Open))
    {
        b = new byte[f.Length];
        f.Read(b, 0, (int)f.Length);
    }


    using (FileStream f2 = new FileStream(fileName, FileMode.Create))
    using (GZipStream gz = new GZipStream(f2, CompressionMode.Compress, false))
    {
        gz.Write(b, 0, b.Length);
    }
    }
4

1 に答える 1

2

.pptx ファイル (.docx および .xlsx も) は既に圧縮されています。ファイル拡張子を .zip に変更してファイルを開くと、内容が表示されます。

したがって、これらのファイルの 1 つを gzip できるはずですが、さらに多くの圧縮が行われる可能性は低いです。

于 2013-01-24T11:55:55.070 に答える