Can I clear the metadata cache?

To clear the metadata cache for an individual file or directory, use the NotifyDirectoryChange method. To clear it for the entire virtual drive, disable and then re-enable the MetadataCacheEnabled property (note that this won't work for files and directories that are currently open; they will retain their "old" attributes).

When calling NotifyDirectoryChange, if you specify any flags other than CBFS_NOTIFY_FLAG_METADATA_MODIFIED, and the file/directory is currently open, then CBFS Connect invalidates all handles to said file/directory. This means any I/O operations using these handles will immediately return an error, and the only successful operation using these handles will be the Windows API's CloseHandle function.

However, if CBFS_NOTIFY_FLAG_METADATA_MODIFIED is the only flag specified, the file/directory's handles remain valid, and only the metadata will be re-requested when necessary (via the appropriate events).

We appreciate your feedback. If you have any questions, comments, or suggestions about this article please contact our support team at