title: Prevent creating compressed file if compression breaks
body: <p>I am using this code to compress files:</p>
  <pre class="lang-cs prettyprint-override"><code>public class GzipCompressor : ICompressor
  {
      public void Compress(string input, string output)
      {
          using (FileStream originalFileStream = File.OpenRead(input))
          using (FileStream compressedFileStream = File.OpenWrite(output))
          using (GZipStream compressor = new GZipStream(compressedFileStream, CompressionMode.Compress))
              originalFileStream.CopyTo(compressor);
      }
  }
  </code></pre>
  <p>The problem is that if someone closes the application while the file is compressing, the file will be saved to the destination path, but it will be invalid (it will not even be able to open it). Is there a way to avoid this? I would prefer such a file not to be created at all in such a situation.</p>