Platform SDK Shell >> Flushing Flash Drive Buffers

by Thom Lamb » Thu, 13 Jan 2005 04:34:24 GMT

Does anyone know how to make certain, or force, that a Flash Drive Write
Buffer has completely been written and is safe to remove. We have folks
that are using flash drives to transport files from one pc to another. The
OS is Win2K. Programmatically we have finished wrting the file. If the
user then removes the device the file usually ends up corrupted. However,
if the user clicks the "unplug or eject hardware" icon and then stops the
device the file is safe to use on the receiving PC.

Thanks,
Thom


Platform SDK Shell >> Flushing Flash Drive Buffers

by Victor Derks » Thu, 13 Jan 2005 06:19:46 GMT


Thom,

Have you already tried to use the Win32 API function FlushFileBuffers?.

You will need a win32 handle to a file. If you use the Win32 CreateFile
functions this is no problem. But if you use a C\C++ file I/O library,
you will need some non-portable function to convert the library file
handle to a win32 handle (you must also make sure that the file library
data is first flushed to the win32 file caching system)

Victor