Can I clear the metadata cache?

You can clear the cache for a separate file/directory by using the NotifyDirectoryChange method.

The cache for the disk as a whole can be cleared by setting the MetaDataCacheEnabled property to false and back to true.

The second method doesn't work for files/directories that are currently opened by programs. That is, opened files still have the "old" attributes.

In the case of NotifyDirectoryChange, if you specify flags other than the fanMetaDataModified (i.e., you specify that file contents have been changed outside CBFS Connect) and a file is currently open, then CBFS Connect makes all handles to the file invalid. This means that any I/O operation with these handles will immediately return an error. The only successful operation will be closing such a handle using the CloseHandle WinAPI function.

In the case that the fanMetaDataModified flag is used and a file is opened, its handles remain valid and only its metadata (file attributes and file size) will be re-requested when it's necessary via the OnGetFileInfo or OnEnumerateDirectory callbacks.

Ready to get started?

Learn more about Callback Technologies or download a free trial.

Download Now