EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Supporting Seek for FileStream in .NET

Also by EldoS: CallbackProcess
A component to control process creation and termination in Windows and .NET applications.
#14921
Posted: 11/02/2010 18:26:38
by Erik Turner (Basic support level)
Joined: 11/02/2010
Posts: 1

How do I support Seek for FileStream in .NET? I can read either the physical drive or the C: partition but the CanSeek property always returns false.

Code
IntPtr diskHandle = CRawDisk.Open(@"\??\C:", GENERIC_READ, licenseKey);
using (SafeFileHandle diskHandleSafe = new SafeFileHandle(diskHandle, true))
{
  using (FileStream readStream = new FileStream(diskHandleSafe, FileAccess.Read))
  {
    Boolean canSeek = readStream.CanSeek;  // CanSeek returns false;
  }
}
#14923
Posted: 11/03/2010 00:43:57
by Eugene Mayevski (EldoS Corp.)

It is better to use ReadFile() Windows API function, however if you want to use .NET class, then you can create a descendant of FileStream class and override CanSeek property to have it return true.


Sincerely yours
Eugene Mayevski

Reply

Statistics

Topic viewed 5049 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!