/// <summary> /// The ReadFile function reads data from a file, starting at the /// position indicated by the file pointer. After the read operation /// has been completed, the file pointer is adjusted by the number /// of bytes actually read, unless the file handle is created with the /// overlapped attribute. If the file handle is created for overlapped /// input and output (I/O), the application must adjust the position of /// the file pointer after the read operation. /// This function is designed for both synchronous and asynchronous /// operation. The ReadFileEx function is designed solely for asynchronous /// operation. It lets an application perform other processing during a /// file read operation. /// </summary> [DllImport("kernel32.dll", SetLastError=true)] private static extern Boolean ReadFile ( IntPtr hFile, [Out] Byte[] lpBuffer, UInt32 nNumberOfBytesToRead, out UInt32 nNumberOfBytesRead, IntPtr lpOverlapped );
对不起,是InBufferCount
/// The ReadFile function reads data from a file, starting at the
/// position indicated by the file pointer. After the read operation
/// has been completed, the file pointer is adjusted by the number
/// of bytes actually read, unless the file handle is created with the
/// overlapped attribute. If the file handle is created for overlapped
/// input and output (I/O), the application must adjust the position of
/// the file pointer after the read operation.
/// This function is designed for both synchronous and asynchronous
/// operation. The ReadFileEx function is designed solely for asynchronous
/// operation. It lets an application perform other processing during a
/// file read operation.
/// </summary>
[DllImport("kernel32.dll", SetLastError=true)]
private static extern Boolean ReadFile
(
IntPtr hFile,
[Out] Byte[] lpBuffer,
UInt32 nNumberOfBytesToRead,
out UInt32 nNumberOfBytesRead,
IntPtr lpOverlapped
);
gotbytes有时会为0。