Win32 HANDLE and StreamReader????

  • Thread starter Thread starter Shawn Anderson
  • Start date Start date
S

Shawn Anderson

Anyone know how I can get a Win32 HANDLE from a StreamReader or
StreamWriter? I want to work with some I/O using Win32 APIs, but I would
like to attach the I/O to a .NET Stream class.

Any suggestions?

Thanks
Shawn
 
I don't think there is such a thing.

however if the underlying stream of your StreamReader is a FileStream you
could try
((FileStream) myStreamReader.BaseStream).Handle
 
For a FileStream, you can get the underlying file's Win32 handle by querying
the Handle property.
For a MemoryStream, I doubt any kind of handle is available.
For a NetworkStream, you can access the underlying socket through the Socket
property. This property is however protected.
 
Back
Top