Esempio n. 1
0
        private int WriteFile(Stream destination, Stream source, FileInfo sourceInfo)
        {
//          int size = 0;
//
//          if( checkBox1.Checked || IsNeedToCompress( sourceInfo ) )
//          {
//              long position = destination.Position;
//              BinaryWriter bw = new BinaryWriter( destination, Encoding.Default );
//              bw.Write( size );
//              bw.Write( ( int )sourceInfo.Length );
//              if( sourceInfo.Length < 100000 )
//              {
//                  size = Compression.Compress( source, destination, 9, true );
//              }
//              else if( sourceInfo.Length < 1000000 )
//              {
//                  size = Compression.Compress( source, destination, 6, true );
//              }
//              else
//              {
//                  size = Compression.Compress( source, destination, 3, true );
//              }
//              destination.Position = position;
//              bw.Write( size );
//              destination.Position += size + 4;
//              size += 8;
//          }
//          else
//          {
//              size = Compression.CopyStream( source, destination );
//          }

            return(Compression.CopyStream(source, destination));;
        }