internal MapPathBasedVirtualPathEnumerator(VirtualPath virtualPath, RequestedEntryType requestedEntryType)
        {
            if (virtualPath.IsRelative)
            {
                throw new ArgumentException(SR.GetString(SR.Invalid_app_VirtualPath), "virtualPath");
            }

            _virtualPath        = virtualPath;
            _requestedEntryType = requestedEntryType;

            string physicalPath;

            if (!ServerConfig.UseServerConfig)
            {
                // Use the hosting environment to map the virtual path
                physicalPath = _virtualPath.MapPathInternal();
            }
            else
            {
                IServerConfig serverConfig = ServerConfig.GetInstance();
                _serverConfig2 = serverConfig as IServerConfig2;

                // Use serverConfig to map the virtual path
                physicalPath = serverConfig.MapPath(null, _virtualPath);

                if (_requestedEntryType != RequestedEntryType.Files)
                {
                    // For MetabaseServerConfig, get the subdirs that are not in the application, and add them to the exclude list.
                    if (_serverConfig2 == null)
                    {
                        string [] virtualSubdirsNotInApp = serverConfig.GetVirtualSubdirs(_virtualPath, false);
                        if (virtualSubdirsNotInApp != null)
                        {
                            _exclude = new Hashtable(StringComparer.OrdinalIgnoreCase);
                            foreach (string subdir in virtualSubdirsNotInApp)
                            {
                                _exclude[subdir] = subdir;
                            }
                        }
                    }

                    // Get subdirs that are virtual directories, and record their physical mappings.
                    // Ignore the virtualPaths if we only need files, since it only contains directories
                    string [] virtualSubdirsInApp = serverConfig.GetVirtualSubdirs(_virtualPath, true);
                    if (virtualSubdirsInApp != null)
                    {
                        _virtualPaths = new Hashtable(StringComparer.OrdinalIgnoreCase);
                        foreach (string subdir in virtualSubdirsInApp)
                        {
                            VirtualPath subpath         = _virtualPath.SimpleCombineWithDir(subdir);
                            string      subPhysicalPath = serverConfig.MapPath(null, subpath);
                            if (FileUtil.DirectoryExists(subPhysicalPath))
                            {
                                _virtualPaths[subdir] = new MapPathBasedVirtualDirectory(subpath.VirtualPathString);
                            }
                        }

                        // Create enumerator for the virtual paths
                        _virtualEnumerator = _virtualPaths.Values.GetEnumerator();
                    }
                }
            }

            // Create an enumerator for the physical files and directories at this path
            _fileEnumerator = FileEnumerator.Create(physicalPath);

            // Reset the enumerator. Note that we don't support the Reset method.
            _useFileEnumerator = false;
        }
    internal MapPathBasedVirtualPathEnumerator(VirtualPath virtualPath, RequestedEntryType requestedEntryType) {

        if (virtualPath.IsRelative) {
            throw new ArgumentException(SR.GetString(SR.Invalid_app_VirtualPath), "virtualPath");
        }

        _virtualPath = virtualPath;
        _requestedEntryType = requestedEntryType;

        string physicalPath;
        if (!ServerConfig.UseServerConfig) {
            // Use the hosting environment to map the virtual path
            physicalPath = _virtualPath.MapPathInternal();
        }
        else {
            IServerConfig serverConfig = ServerConfig.GetInstance();
            _serverConfig2 = serverConfig as IServerConfig2;
            
            // Use serverConfig to map the virtual path
            physicalPath = serverConfig.MapPath(null, _virtualPath);

            if (_requestedEntryType != RequestedEntryType.Files) {
                // For MetabaseServerConfig, get the subdirs that are not in the application, and add them to the exclude list.
                if (_serverConfig2 == null) {
                    string [] virtualSubdirsNotInApp = serverConfig.GetVirtualSubdirs(_virtualPath, false);
                    if (virtualSubdirsNotInApp != null) {
                        _exclude = new Hashtable(StringComparer.OrdinalIgnoreCase);
                        foreach (string subdir in virtualSubdirsNotInApp) {
                            _exclude[subdir] = subdir;
                        }
                    }
                }

                // Get subdirs that are virtual directories, and record their physical mappings.
                // Ignore the virtualPaths if we only need files, since it only contains directories
                string [] virtualSubdirsInApp = serverConfig.GetVirtualSubdirs(_virtualPath, true);
                if (virtualSubdirsInApp != null) {
                    _virtualPaths = new Hashtable(StringComparer.OrdinalIgnoreCase);
                    foreach (string subdir in virtualSubdirsInApp) {
                        VirtualPath subpath = _virtualPath.SimpleCombineWithDir(subdir);
                        string subPhysicalPath = serverConfig.MapPath(null, subpath);
                        if (FileUtil.DirectoryExists(subPhysicalPath)) {
                            _virtualPaths[subdir] = new MapPathBasedVirtualDirectory(subpath.VirtualPathString);
                        }
                    }

                    // Create enumerator for the virtual paths
                    _virtualEnumerator = _virtualPaths.Values.GetEnumerator();
                }
            }
        }

        // Create an enumerator for the physical files and directories at this path
        _fileEnumerator = FileEnumerator.Create(physicalPath);

        // Reset the enumerator. Note that we don't support the Reset method.
        _useFileEnumerator = false;
    }