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);
}
}