Example #1
0
 public void CancelIO()
 {
     if (IsOpen)
     {
         NativeMethods.CancelIoEx(SafeReadHandle.DangerousGetHandle(), IntPtr.Zero);
     }
 }
Example #2
0
 public ReadStatus ReadFile(byte[] inputBuffer)
 {
     EnsureReadHandleActive();
     try
     {
         if (NativeMethods.ReadFile(SafeReadHandle.DangerousGetHandle(), inputBuffer, (uint)inputBuffer.Length, out uint bytesRead, IntPtr.Zero))
         {
             return(ReadStatus.Success);
         }
         else
         {
             return(ReadStatus.NoDataRead);
         }
     }
Example #3
0
        private void CloseFileStreamIO()
        {
            if (FileStream != null)
            {
                try { FileStream.Close(); } catch { }
            }

            FileStream = null;

            if (SafeReadHandle != null && !SafeReadHandle.IsInvalid)
            {
                try
                {
                    if (!SafeReadHandle.IsClosed)
                    {
                        SafeReadHandle.Close();
                    }
                }
                catch (IOException) { }
            }

            SafeReadHandle = null;
        }