Ejemplo n.º 1
0
        bool VirtualDirectoryExists(string virtualPath, HttpWorkerRequest worker)
        {
            VirtualPathProvider vpp = HostingEnvironment.VirtualPathProvider;
            // TODO: Remove the second condition of the "if" statement (it is only a workaround) involving DefaultVirtualPathProvider as soon as Mono's DefaultVirtualPathProvider.DirectoryExists method works properly (i.e., the indirectly-called HostingEnvironment.MapPath method should not require an HttpContext.Current.Request object to do its work; also see the comment in the ApplicationHost.MapPath method above)
            if (vpp != null && !vpp.GetType().FullName.Equals("System.Web.Hosting.DefaultVirtualPathProvider", StringComparison.Ordinal))
                return vpp.DirectoryExists (virtualPath);

            string physicalPath = (worker != null) ? worker.MapPath (virtualPath) : MapPath (virtualPath);
            return Directory.Exists (physicalPath);
        }