Can I flush the disk cache?



I'm trying to detect data corruption on a usb hard drive.
My test program writes then reads the disk, but never finds
any corruption. But if I unmount/unplug and replug the usb, the
corruption appears.

It occurs that Windows 2k/xp has cached the small files.
Since the changes didn't come thru the OS, the OS thinks the
data is good and just hands me what's in the cache from the previous
read.
I'm trying to do this with simple VB6 (legacy) code:

Open filenamestring For Input As #1
inputstring = Input(14, #1)
Close #1

to keep it simple.

Is there a way to force the OS to flush the disk buffers/cache and give
me what's actually on the disk the next time I open the file?

Or maybe unmount/remount the usb drive?

Or do I need a more complicated file handler?

Or maybe I'm barking up the wrong tree??? Better tree?

I've googled for cache, flush, buffer and unbuffered and every
combination I can think of. Nothing useful found.
Thanks, mike
--
Return address is VALID!
.



Relevant Pages

  • Can I force a read operation to actually read the media?
    ... But if I unmount/unplug and replug the usb, ... >> corruption appears. ... >> Is there a way to force the OS to flush the disk buffers/cache and give ...
    (microsoft.public.vb.winapi)
  • Re: Can I flush the disk cache?
    ... But if I unmount/unplug and replug the usb, ... corruption appears. ... Is there a way to force the OS to flush the disk buffers/cache and give ...
    (comp.arch.storage)
  • Re: Can I flush the disk cache?
    ... But if I unmount/unplug and replug the usb, ... corruption appears. ... Is there a way to force the OS to flush the disk buffers/cache and give ...
    (comp.arch.storage)
  • Re: --++[Preventing the spread of USB malware]++--
    ... "/Flash_Disinfector will create a hidden folder named autorun.inf in each partition and every USB drive that is plugged in when you ran it. ... Don't delete this folder...it will help protect your drives from future ... > Malware uses two main techniques to spread through memory sticks. ... > the disk in a hex editor. ...
    (Pen-Test)
  • Re: Somewhat OT: Cant write files to a perfectly good CD
    ... emergencies and I also have the external USB hard disks to allow me to ... to floppy disk; I've lost three or four floppy disks' worth of data out ... My Fantom 200 GB hard disk wouldn't mount through an unpowered hub, ... Bottom line--not all USB drives are created equal, ...
    (misc.transport.road)