예제 #1
0
 public long CopyTo(UnsafeNativeMethodsR.IStream pstm, long cb, long[] pcbRead)
 {
     int cb1 = 4096;
     IntPtr num1 = Marshal.AllocHGlobal(cb1);
     if (num1 == IntPtr.Zero)
         throw new OutOfMemoryException();
     long num2 = 0L;
     try
     {
         while (num2 < cb)
         {
             int length = cb1;
             if (num2 + (long)length > cb)
                 length = (int)(cb - num2);
             int len = this.Read(num1, length);
             if (len != 0)
             {
                 if (pstm.Write(num1, len) != len)
                     throw UnsafeNativeMethodsR.ComStreamFromDataStream.EFail("Wrote an incorrect number of bytes");
                 num2 += (long)len;
             }
             else
                 break;
         }
     }
     finally
     {
         Marshal.FreeHGlobal(num1);
     }
     if (pcbRead != null && pcbRead.Length > 0)
         pcbRead[0] = num2;
     return num2;
 }