EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Supporting Seek for FileStream in .NET

Also by EldoS: BizCrypto
Components for BizTalk® and SQL Server® Integration Services that let you securely store and transfer information in your business automation solutions.
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.

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;
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



Topic viewed 4931 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!