DeflateStream / GZipStream to CryptoStream and vice versa
问题 I want to to compress and encrypt a file in one go by using this simple code: public void compress(FileInfo fi, Byte[] pKey, Byte[] pIV) { // Get the stream of the source file. using (FileStream inFile = fi.OpenRead()) { // Create the compressed encrypted file. using (FileStream outFile = File.Create(fi.FullName + ".pebf")) { using (CryptoStream encrypt = new CryptoStream(outFile, Rijndael.Create().CreateEncryptor(pKey, pIV), CryptoStreamMode.Write)) { using (DeflateStream cmprss = new