My question is a slight variation on the question What is the best way to test whether a file exists on Windows?, with some specific caveats. Specifically, the data is located on a mapped drive, and the SMB 2.0 protocol is used. (By definition, this requires that the drive be mapped from a Vista machine to either a Vista or Server 2008 machine.)
The problem with the answers posted in reply to the above question is that SMB 2.0 caches a bunch of metadata, including filenames in a given directory. As a result, if you are testing for the existence of a file that was just created, then functions _access, access, GetFileAttributes, and CreateFile (and perhaps others) will all use cached information to answer the question "does this file exist?". If the file was very recently created by another user, the cache indicates that the file is not present, despite the fact that it does indeed exist. I've set up test environments to test this, and I can confirm that no SMB2 traffic is generated by the client for several seconds [presumably the cache expires every 5 seconds or so].
Has anyone else seen this? (If so, did you find a workaround other than adding a delay/retry?) Does anyone know of any API similar to the above that can check for file existence without using the SMB cache? Or, better yet, does anyone know of a Windows API that will simply dump the cached SMB metadata?