Re: Clearing file cache to read what's really on disk
- Posted by jimcbrown (admin) Feb 06, 2012
- 1577 views
I use Win7 and Eu3.1 with Win32Lib. I have a data logging program that saves data on networked drive; it opens, appends, and closes. That is fine. If I read that file, all is fine. But if I read it again I get the cached version and not the real data which is on disk.
I'm curious, does this only happen with NetDrive network drive? Do you have the same problem when using regular mapped network drives to a share on another computer?
Is it possible to force a disk open or disk read to access the actual data and not the cached data? I want to have a program accessing the data on a regular basis to see how the data logger is doing, but all I get is the same old data over and over. I often want to access this file from home; I use NetDrive which accesses the data by FTP; I'm sure that is getting the data but I'm not. When I'm at work I go straight to the file on our server with on the internal network but the result is the same.
Actually, it's probably not going there. At least not right away. A few articles on NetDrive imply that you'll need to manually flush the cache yourself to ensure that all the data is really transferred over.
http://www.freewaregenius.com/2007/09/18/netdrive/
http://www.muhlenberg.edu/main/aboutus/oit/faculty_computing/remote_access/net_drive.html
Of course, they explain how to flush the cache, but only through the shell extension. I don't know how to do it programatically (aside from the obviously problematic method of programmically taking control of the mouse and keyboard to mimic a user performing the actions to trigger a manual flush).
Does anyone have any ideas? I could build in the FTP access to my program but that does seem like hard work. And I'm not completely sure that is right anyway.
Andy
Building in FTP access directly is probably the right way to do it. You can go full out making a new FTP library (and even submitting it to the dev team to get it included in the standard library) or probably go the easier route of reading and writing to temp files and then manipulating ftp.exe (using pipeio:exec() and friends) to do the heavy lifting for you.
I can think of other ways to do achieve this - set up a Linux/GNU or FreeBSD or other *nix system with FUSE supported, install an FTP-FS like curlftpfs, mount the ftp server using the FTP-FS on the *nix system, share it as a regular CIFS share via Samba, then map the Samba share on your Windoze 7 system as a regular mapped drive. For example.
Yeah... building in FTP access is probably the right way to do it. Just saying.