USB Mass Storage

  • Thread starter Thread starter Graham Stevenson
  • Start date Start date
G

Graham Stevenson

Hi,

I have a USB mass storage device being developed by
colleagues, and need to interface that to a Windows Forms
application (C#). The device is neither purely a storage
device nor an HID device, it is a combination of the two,
so it seems expedient to use files to communicate PC <->
Device.

The device can read AND WRITE files.

I can write and read the files, but they appear to be
cached ??. If the timestamp is changed by the device,
Windows does not see this change unless an 'Eject'
command is performed on the drive.

Have tried DirectoryInfo and FileInfo classes, as well as
a FileSystemWatcher (but I guess this uses the FileIO OS,
so won't see external changes). None of these can see the
new timestamp until the 'Eject' has been implemented.

How can I achieve this please - or how can I force the
cached file information to be refreshed, so that I can
see the change. Maybe do an 'Eject' programmatically ??? -
could be dangerous just to see a filestamp!!.

Thanks

Graham
 
Thanks for the comment, but if its 'Just a Drive' - why
doesn't it update its timestamp, when the device changes
it ?? - until I select 'Eject' for the drive.

Device has a file with given timestamp.
Read this in a .Net app = fine.
Device changes the timestamp.
Read in .Net and it has not changed.
Eject.
Read in .Net and it now has changed.

The point being that the device itself can change the
file parameters - all I want to do is to force Windows to
recognise that change, so that I can monitor it.

Thanks

Graham
 
You need to use AutoFlush or call .Flush() i guess as its not written
immediatlly its buffered, right?
 
I (or my PC app) are not writing to the file, so I don't
have anything to Flush.

The USB device is a two-way device, which is capable of
changing a file, hence why the device (not Windows)
changes the timestamp, and I am trying to get Windows
to 'see' this change - without the need for an 'Eject' -
or even with an 'Eject' if I can issue this from my
Windows app - but I don't know how to without the need
for a new device driver.

It must be possible for a windows app to send an 'Eject'
command - as Windows Explorer can do it, but I can't find
how to having trawled MSDN, Web etc.

Graham
 
Cant you use the File system watcher like a normal file? Then you can get
notified once its changed?
 
Back
Top