/// <summary>
        /// Changes the seek pointer to a new location relative to the beginning
        ///of the stream, the end of the stream, or the current seek pointer
        /// </summary>
        /// <param name="dlibMove">
        /// The displacement to be added to the location indicated by the dwOrigin parameter.
        /// If dwOrigin is STREAM_SEEK_SET, this is interpreted as an unsigned value rather than a signed value.
        /// </param>
        /// <param name="dwOrigin">
        /// The origin for the displacement specified in dlibMove.
        /// The origin can be the beginning of the file (STREAM_SEEK_SET), the current seek pointer (STREAM_SEEK_CUR), or the end of the file (STREAM_SEEK_END).
        /// </param>
        /// <param name="plibNewPosition">
        /// The location where this method writes the value of the new seek pointer from the beginning of the stream.
        /// It can be set to IntPtr.Zero. In this case, this method does not provide the new seek pointer.
        /// </param>
        /// <typeparam name="pcbRead">Native UInt64</typeparam>
        /// <returns>
        /// Returns in <paramref name="plibNewPosition"/> the location where this method writes the value of the new seek pointer from the beginning of the stream.
        /// </returns>
        ///<exception cref="IOException">An I/O error occurs.</exception>
        ///<exception cref="NotSupportedException">The stream does not support reading.</exception>
        ///<exception cref="ObjectDisposedException">Methods were called after the stream was closed.</exception>
        public void Seek(long dlibMove, int dwOrigin, IntPtr plibNewPosition)
        {
            if (TheStream != null)
            {
                // The enum values of SeekOrigin match the enum values of
                // STREAM_SEEK, so we can just cast the dwOrigin to a SeekOrigin

                if (plibNewPosition == IntPtr.Zero)
                {
                    // User isn't interested in new position
                    TheStream.Seek(dlibMove, (SeekOrigin)dwOrigin);
                }
                else
                {
                    var origin = (SeekOrigin)dwOrigin;
                    if (origin != SeekOrigin.Begin &&
                        origin != SeekOrigin.Current &&
                        origin != SeekOrigin.End)
                    {
                        origin = SeekOrigin.Begin;
                    }
                    Marshal.WriteInt64(plibNewPosition, TheStream.Seek(dlibMove, origin));
                }
            }
            else
            {
                TheIStream.Seek(dlibMove, dwOrigin, plibNewPosition);
            }
        }
        /// <summary>
        /// Sets the position within the current stream.
        /// </summary>
        /// <param name="offset">A byte offset relative to the origin parameter.</param>
        /// <param name="origin">A value of type SeekOrigin indicating the reference point used to obtain the new position.</param>
        /// <returns>The new position within the current stream.</returns>
        public override long Seek(long offset, System.IO.SeekOrigin origin)
        {
            if (TheIStream != null)
            {
                long position = 0;
                var  pos      = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(long)));
                Marshal.WriteInt64(pos, 0);

                // The enum values of SeekOrigin match the enum values of
                // STREAM_SEEK, so we can just cast the origin to an integer.
                TheIStream.Seek(offset, (int)origin, pos);
                position = Marshal.ReadInt64(pos);

                Marshal.FreeHGlobal(pos);

                return(position);
            }
            else
            {
                return(TheStream.Seek(offset, origin));
            }
        }