HighTechTalks DotNet Forums  

Bypassing Disk Caching

Dotnet Framework microsoft.public.dotnet.framework


Discuss Bypassing Disk Caching in the Dotnet Framework forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
sturnfie@gmail.com
 
Posts: n/a

Default Bypassing Disk Caching - 02-16-2007 , 07:36 PM






Anyone know a way to bypass disk caching in Windows XP?

I am working on a C# program that needs to verify the integrity of
data that was copied to a removable drive. My approach is to read the
data back and compare it to the original data source. Problem is,
this process is happening way too quickly to be possible.

I used filemon to see what the file system is doing when I attempt to
copy back the file I just wrote to the removable drive, and although
there are tons of FASTIO_WRITE requests directing chucks of the data
to a local file (a file that holds a "copy" of the removable drive's
data), there is not a single request for any information from the
external drive.

My best guess is that the entire file is still in the local disk's
cache; this would explain the super speeds I am seeing.

So my question(s): Is there a way to force windows to not use the
disk cache? If not, is there a way to flush the disk cache? Is there
another workaround someone can suggest?

I am going to start trying to hack something together to fool it
(maybe renaming the file on the external drive will be enough to fool
it), but thanks in advance to anyone who knows a proper way to handle
this problem.

--
lucas


Reply With Quote
  #2  
Old   
Barry Kelly
 
Posts: n/a

Default Re: Bypassing Disk Caching - 02-17-2007 , 04:39 AM






sturnfie (AT) gmail (DOT) com wrote:

Quote:
Anyone know a way to bypass disk caching in Windows XP?
Yes, use FILE_FLAG_NO_BUFFERING with CreateFile. That'll require
P/Invoke etc., and there are other restrictions, like working with
aligned buffers of specific sizes etc.

Quote:
If not, is there a way to flush the disk cache?
FlushFileBuffers is the function to use, again with P/Invoke.

-- Barry

--
http://barrkel.blogspot.com/


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.