예제 #1
0
 public unsafe void Write(byte *pBuffer, int count)
 {
     this.CheckDisposed("ComStream::Write");
     Util.InvokeComCall(MsgStorageErrorCode.FailedWrite, delegate
     {
         int num = 0;
         this.iStream.Write(pBuffer, count, out num);
         if (num != count)
         {
             throw new MsgStorageException(MsgStorageErrorCode.FailedWrite, MsgStorageStrings.FailedWrite(string.Empty));
         }
     });
 }
예제 #2
0
 public unsafe void WriteBytesToStream(string streamName, byte[] data, int length)
 {
     this.CheckDisposed("ComStream::WriteToStream");
     Util.ThrowOnNullArgument(streamName, "streamName");
     Util.ThrowOnNullArgument(data, "data");
     Util.InvokeComCall(MsgStorageErrorCode.FailedWrite, delegate
     {
         Interop.IStream stream = null;
         try
         {
             int num = 0;
             this.iStorage.CreateStream(streamName, 17U, 0U, 0U, out stream);
             if (length != 0)
             {
                 try
                 {
                     fixed(byte *ptr = &data[0])
                     {
                         stream.Write(ptr, length, out num);
                     }
                 }
                 finally
                 {
                     byte *ptr = null;
                 }
             }
             if (num != length)
             {
                 throw new MsgStorageException(MsgStorageErrorCode.FailedWrite, MsgStorageStrings.FailedWrite(streamName));
             }
         }
         finally
         {
             if (stream != null)
             {
                 Marshal.ReleaseComObject(stream);
             }
         }
     });
 }