In my web app the following call returns true early during application startup, then returns false later for whatever reason:
HostingEnvironment.VirtualPathProvider.DirectoryExists("~/some/existing/directory")
The folder exists and at the same time the following code always correctly returns true:
System.IO.Directory.Exists(HostingEnvironment.MapPath("~/some/existing/directory"))
I have no idea what can affect VirtualPathProvider to change behaviour. The VirtualPathProvider is overridden on application start with a custom implementation but that doesn't override DirectoryExists() and the method actually called all times is System.Web.Hosting.MapPathBasedVirtualPathProvider
.
I checked with Process Monitor and the file system operation that happens is the same for the right and the wrong result.
Anybody with an idea what can break DirectoryExists()
(and BTW the same happens for FileExists()
)?