Question: I have the following method and for some reason the first call to Copy to seems to do nothing? Anyone know why?
In input to the method is compressed and base64 can supply that method to if need.

```
private byte[] GetFileChunk(string base64)
    {
        using (
            MemoryStream compressedData = new MemoryStream(Convert.FromBase64String(base64), false),
            uncompressedData = new MemoryStream())
        {

            using (GZipStream compressionStream = new GZipStream(compressedData, CompressionMode.Decompress))
            {
                // first copy does nothing ?? second works
                compressionStream.CopyTo(uncompressedData);
                compressionStream.CopyTo(uncompressedData);
            }

            return uncompressedData.ToArray();
        }
    }

```

Answer: 
If the first call to Read() returns 0 then Stream.CopyTo() isn't going to work either. While this points to a problem with GZipStream, it is *very* unlikely that it has a bug like this. Far more likely is that something went wrong when you created the compressed data. Like compressing 0 bytes first, followed by compressing the real data.
Hi thank you for everybody’s input. It turns out the error was caused by a mistake in encoding method. The method was

```
  /// <summary>
    /// Compress file data and then base64s the compressed data for safe transportation in XML.
    /// </summary>
    /// <returns>Base64 string of file chunk</returns>
    private string GetFileChunk()
    {
        // MemoryStream for compression  output
        using (MemoryStream compressed = new MemoryStream())
        {
            using (GZipStream zip = new GZipStream(compressed, CompressionMode.Compress))
            {

                // read chunk from file
                byte[] plaintext = new byte[this.readSize];
                int read = this.file.Read(plaintext, 0, plaintext.Length);

                // write chunk to compreesion
                zip.Write(plaintext, 0, read);
                plaintext = null;

                // Base64 compressed data
                return Convert.ToBase64String(compressed.ToArray());
            }
        }
    }

```

The return line should be below the using allowing the compression stream to close and flush, this caused the inconsistent behaviour when decompressing the stream. 

```
        /// <summary>
    /// Compress file data and then base64s the compressed data for safe transportation in XML.
    /// </summary>
    /// <returns>Base64 string of file chunk</returns>
    private string GetFileChunk()
    {
        // MemoryStream for compression  output
        using (MemoryStream compressed = new MemoryStream())
        {
            using (GZipStream zip = new GZipStream(compressed, CompressionMode.Compress))
            {

                // read chunk from file
                byte[] plaintext = new byte[this.readSize];
                int read = this.file.Read(plaintext, 0, plaintext.Length);

                // write chunk to compreesion
                zip.Write(plaintext, 0, read);
                plaintext = null;
            }

            // Base64 compressed data
            return Convert.ToBase64String(compressed.ToArray());
        }
    }

```

Thank you for everybody's help.