[]
Windows File Helper.
public class NativeFileStream : Stream, IDisposable
Initializes a new instance of the NativeFileStream class.
public NativeFileStream(string fileName, NativeFileMode fileMode, NativeFileAccess access, NativeFileShare share = NativeFileShare.Read)
fileName
stringName of the file.
fileMode
NativeFileModeThe file mode.
access
NativeFileAccessThe access mode.
share
NativeFileShareThe share mode.
public override bool CanRead { get; }
public override bool CanSeek { get; }
public override bool CanWrite { get; }
Gets the stream handle.
public IntPtr Handle { get; }
public override long Length { get; }
public override long Position { get; set; }
protected override void Dispose(bool disposing)
disposing
boolpublic override void Flush()
public override int Read(byte[] buffer, int offset, int count)
buffer
byte[]offset
intcount
intReads a block of bytes from the stream and writes the data in a given buffer.
public int Read(IntPtr buffer, int offset, int count)
buffer
System.IntPtrWhen this method returns, contains the specified buffer with the values between offset and (offset + count - 1) replaced by the bytes read from the current source.
offset
intThe byte offset in array at which the read bytes will be placed.
count
intThe maximum number of bytes to read.
The total number of bytes read into the buffer. This might be less than the number of bytes requested if that number of bytes are not currently available, or zero if the end of the stream is reached.
array is null.
public override long Seek(long offset, SeekOrigin origin)
offset
longorigin
System.IO.SeekOriginpublic override void SetLength(long value)
value
longpublic override void Write(byte[] buffer, int offset, int count)
buffer
byte[]offset
intcount
intWrites a block of bytes to this stream using data from a buffer.
public void Write(IntPtr buffer, int offset, int count)
buffer
System.IntPtrThe buffer containing data to write to the stream.
offset
intThe zero-based byte offset in buffer at which to begin copying bytes to the current stream.
count
intThe number of bytes to be written to the current stream.