VirtualPathProvider 类

定义

提供了一组方法,使 Web 应用程序可以从虚拟文件系统中检索资源。Provides a set of methods that enable a Web application to retrieve resources from a virtual file system.

public ref class VirtualPathProvider abstract : MarshalByRefObject
public abstract class VirtualPathProvider : MarshalByRefObject
type VirtualPathProvider = class
    inherit MarshalByRefObject
Public MustInherit Class VirtualPathProvider
Inherits MarshalByRefObject
继承
VirtualPathProvider

示例

下面的代码示例是一个VirtualPathProvider类实现, 它使用存储DataSet在对象中的信息创建虚拟文件系统。The following code example is a VirtualPathProvider class implementation that creates a virtual file system using information stored in a DataSet object. 此代码示例使用VirtualFileVirtualDirectory类的代码示例, 以从加载到DataSet对象的数据存储区中提供虚拟资源。The code example works with the code examples for the VirtualFile and VirtualDirectory classes to provide virtual resources from a data store that is loaded into a DataSet object.

此示例包含四个部分: VirtualPathProvider类实现、用于DataSet填充对象的 XML 数据文件、 AppStart包含AppInitialize用于将VirtualPathProvider类注册到编译的方法的对象。系统, 以及提供指向虚拟文件的链接的 ASP.NET 页面。This example has four parts: the VirtualPathProvider class implementation, an XML data file used to populate the DataSet object, an AppStart object that contains an AppInitialize method used to register the VirtualPathProvider class with the compilation system, and an ASP.NET page that provides links to the virtual files.

若要在应用程序中使用此示例代码, 请执行以下步骤。To use this sample code in an application, follow these steps.

  1. 在 Web 服务器上创建一个示例应用程序。Create a sample application on your Web server.

  2. 将自定义VirtualPathProvider对象的源代码 (见下文) 复制到App_Code应用程序目录中的文件。Copy the source code for the custom VirtualPathProvider object (see below) into a file in the application's App_Code directory.

  3. 将自定义VirtualDirectory对象的源代码 (请参阅VirtualDirectory类概述主题中的 "示例" 部分) 复制到应用程序App_Code目录中的文件。Copy the source code for the custom VirtualDirectory object (see the Example section in the VirtualDirectory class overview topic) into a file in the application's App_Code directory.

  4. 将自定义VirtualFile对象的源代码 (请参阅VirtualFile类概述主题中的 "示例" 部分) 复制到应用程序App_Code目录中的文件。Copy the source code for the custom VirtualFile object (see the Example section in the VirtualFile class overview topic) into a file in the application's App_Code directory.

  5. AppStart对象的源代码 (见下文) 复制到App_Code应用程序目录中的文件。Copy the source code for the AppStart object (see below) into a file in the application's App_Code directory.

  6. 将 XML 数据 (见下文) 复制到XMLData.xml App_Data应用程序目录中的文件中。Copy the XML data (see below) into a file named XMLData.xml into a file in the application's App_Data directory.

  7. default.aspx将文件 (见下文) 复制到示例应用程序的根目录中。Copy the default.aspx file (see below) into the root directory of the sample application. 使用 Web 浏览器打开default.aspx文件, 然后单击页面上的链接以查看虚拟文件的内容。Use a Web browser to open the default.aspx file, and then click the links on the page to see the contents of the virtual files.

第一个示例是自定义VirtualPathProvider类。The first example is a custom VirtualPathProvider class. 重写FileExists和方法, 以指示请求的目录是否存在于虚拟文件系统中。 DirectoryExistsThe DirectoryExists and FileExists methods are overridden to indicate whether a requested directory is present in the virtual file system. 重写GetFile和方法, 以返回包含VirtualDirectory虚拟VirtualFile文件系统中的信息的自定义和实例。 GetDirectoryThe GetDirectory and GetFile methods are overridden to return custom VirtualDirectory and VirtualFile instances containing information from the virtual file system.

类还提供GetVirtualDataVirtualDirectory VirtualFile和类用于访问包含虚拟文件系统数据的对象的方法。DataSetThe class also provides a GetVirtualData method used by the VirtualDirectory and VirtualFile classes to access the DataSet object containing the virtual file system data. 在生产实现中, 通常会在负责与数据存储区交互的业务对象中实现此方法。In a production implementation, this method would typically be implemented in a business object responsible for interacting with the data store.

using System;
using System.Data;
using System.Security.Permissions;
using System.Web;
using System.Web.Caching;
using System.Web.Hosting;

namespace Samples.AspNet.CS
{
  [AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Medium)]
  [AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.High)]
  public class SamplePathProvider : VirtualPathProvider
  {
    private string dataFile;

    public SamplePathProvider()
      : base()
    {
    }

    protected override void Initialize()
    {
      // Set the datafile path relative to the application's path.
      dataFile = HostingEnvironment.ApplicationPhysicalPath + "App_Data\\XMLData.xml";
    }

    /// <summary>
    ///   Data set provider for the SampleVirtualDirectory and
    ///   SampleVirtualFile classes. In a production application
    ///   this method would be on a provider class that accesses
    ///   the virtual resource data source.
    /// </summary>
    /// <returns>
    ///   The System.Data.DataSet containing the virtual resources 
    ///   provided by the SamplePathProvider.
    /// </returns>
    public DataSet GetVirtualData()
    {
      // Get the data from the cache.
      DataSet ds = (DataSet)HostingEnvironment.Cache.Get("VPPData");
      if (ds == null)
      {
        // Data not in cache. Read XML file.
        ds = new DataSet();
        ds.ReadXml(dataFile);

        // Make DataSet dependent on XML file.
        CacheDependency cd = new CacheDependency(dataFile);

        // Put DataSet into cache for maximum of 20 minutes.
        HostingEnvironment.Cache.Add("VPPData", ds, cd,
          Cache.NoAbsoluteExpiration,
          new TimeSpan(0, 20, 0),
          CacheItemPriority.Default, null);

        // Set data timestamp.
        DateTime dataTimeStamp = DateTime.Now;
        // Cache it so we can get the timestamp in later calls.
        HostingEnvironment.Cache.Insert("dataTimeStamp", dataTimeStamp, null,
          Cache.NoAbsoluteExpiration,
          new TimeSpan(0, 20, 0),
          CacheItemPriority.Default, null);
      }
      return ds;
    }

    /// <summary>
    ///   Determines whether a specified virtual path is within
    ///   the virtual file system.
    /// </summary>
    /// <param name="virtualPath">An absolute virtual path.</param>
    /// <returns>
    ///   true if the virtual path is within the 
    ///   virtual file sytem; otherwise, false.
    /// </returns>
    private bool IsPathVirtual(string virtualPath)
    {
      String checkPath = VirtualPathUtility.ToAppRelative(virtualPath);
      return checkPath.StartsWith("~/vrdir", StringComparison.InvariantCultureIgnoreCase);
    }

    public override bool FileExists(string virtualPath)
    {
      if (IsPathVirtual(virtualPath))
      {
        SampleVirtualFile file = (SampleVirtualFile)GetFile(virtualPath);
        return file.Exists;
      }
      else
            {
                return Previous.FileExists(virtualPath);
            }
        }

    public override bool DirectoryExists(string virtualDir)
    {
      if (IsPathVirtual(virtualDir))
      {
        SampleVirtualDirectory dir = (SampleVirtualDirectory)GetDirectory(virtualDir);
        return dir.Exists;
      }
      else
            {
                return Previous.DirectoryExists(virtualDir);
            }
        }

    public override VirtualFile GetFile(string virtualPath)
    {
      if (IsPathVirtual(virtualPath))
        return new SampleVirtualFile(virtualPath, this);
      else
        return Previous.GetFile(virtualPath);
    }

    public override VirtualDirectory GetDirectory(string virtualDir)
    {
      if (IsPathVirtual(virtualDir))
        return new SampleVirtualDirectory(virtualDir, this);
      else
        return Previous.GetDirectory(virtualDir);
    }

    public override CacheDependency GetCacheDependency(
      string virtualPath, 
      System.Collections.IEnumerable virtualPathDependencies, 
      DateTime utcStart)
    {
      if (IsPathVirtual(virtualPath))
      {
        System.Collections.Specialized.StringCollection fullPathDependencies = null;

        // Get the full path to all dependencies.
        foreach (string virtualDependency in virtualPathDependencies)
        {
          if (fullPathDependencies == null)
            fullPathDependencies = new System.Collections.Specialized.StringCollection();

          fullPathDependencies.Add(virtualDependency);
        }
        if (fullPathDependencies == null)
          return null;

        // Copy the list of full-path dependencies into an array.
        string[] fullPathDependenciesArray = new string[fullPathDependencies.Count];
        fullPathDependencies.CopyTo(fullPathDependenciesArray, 0);
        // Copy the virtual path into an array.
        string[] virtualPathArray = new string[1];
        virtualPathArray[0] = virtualPath;

        return new CacheDependency(virtualPathArray, fullPathDependenciesArray, utcStart);
      }
      else
            {
                return Previous.GetCacheDependency(virtualPath, virtualPathDependencies, utcStart);
            }
        }
  }
}

Imports System.Data
Imports System.Security.Permissions
Imports System.Web
Imports System.Web.Caching
Imports System.Web.Hosting


Namespace Samples.AspNet.VB
  <AspNetHostingPermission(SecurityAction.Demand, Level:=AspNetHostingPermissionLevel.Medium), _
   AspNetHostingPermission(SecurityAction.InheritanceDemand, level:=AspNetHostingPermissionLevel.High)> _
  Public Class SamplePathProvider
    Inherits VirtualPathProvider

    Private dataFile As String

    Public Sub New()
      MyBase.New()
    End Sub

    Protected Overrides Sub Initialize()
      ' Set the datafile path relative to the application's path.
      dataFile = HostingEnvironment.ApplicationPhysicalPath & _
        "App_Data\XMLData.xml"
    End Sub

    '   Data set provider for the SampleVirtualFile and
    '   SampleVirtualDirectory classes. In a production application
    '   this method would be on a provider class that accesses
    '   the virtual resource data source.
    '   The System.Data.DataSet containing the virtual resources
    '   provided by the SamplePathProvider.
    Public Function GetVirtualData() As DataSet
      ' Get the data from the cache.
      Dim ds As DataSet
      ds = CType(HostingEnvironment.Cache.Get("VPPData"), DataSet)

      If ds Is Nothing Then
        ' Data set not in cache. Read XML file.
        ds = New DataSet
        ds.ReadXml(dataFile)

        ' Make DataSet dependent on XML file.
        Dim cd As CacheDependency
        cd = New CacheDependency(dataFile)

        ' Put DataSet into cache for maximum of 20 minutes.
        HostingEnvironment.Cache.Add("VPPData", ds, cd, _
         Cache.NoAbsoluteExpiration, _
         New TimeSpan(0, 20, 0), _
         CacheItemPriority.Default, Nothing)

        ' Set data timestamp.
        Dim dataTimeStamp As DateTime
        dataTimeStamp = DateTime.Now
        ' Cache it so we can get the timestamp in later calls.
        HostingEnvironment.Cache.Add("dataTimeStamp", dataTimeStamp, Nothing, _
          Cache.NoAbsoluteExpiration, _
          New TimeSpan(0, 20, 0), _
          CacheItemPriority.Default, Nothing)
      End If
      Return ds
    End Function

    Private Function IsPathVirtual(ByVal virtualPath As String) As Boolean
      Dim checkPath As String
      checkPath = VirtualPathUtility.ToAppRelative(virtualPath)
      Return checkPath.StartsWith("~/vrdir", StringComparison.InvariantCultureIgnoreCase)
    End Function

    Public Overrides Function FileExists(ByVal virtualPath As String) As Boolean
      If (IsPathVirtual(virtualPath)) Then
        Dim file As SampleVirtualFile
        file = CType(GetFile(virtualPath), SampleVirtualFile)
        Return file.Exists
      Else
        Return Previous.FileExists(virtualPath)
      End If
    End Function

    Public Overrides Function DirectoryExists(ByVal virtualDir As String) As Boolean
      If (IsPathVirtual(virtualDir)) Then
        Dim dir As SampleVirtualDirectory
        dir = CType(GetDirectory(virtualDir), SampleVirtualDirectory)
        Return dir.exists
      Else
        Return Previous.DirectoryExists(virtualDir)
      End If
    End Function

    Public Overrides Function GetFile(ByVal virtualPath As String) As VirtualFile
      If (IsPathVirtual(virtualPath)) Then
        Return New SampleVirtualFile(virtualPath, Me)
      Else
        Return Previous.GetFile(virtualPath)
      End If
    End Function

    Public Overrides Function GetDirectory(ByVal virtualDir As String) As VirtualDirectory
      If (IsPathVirtual(virtualDir)) Then
        Return New SampleVirtualDirectory(virtualDir, Me)
      Else
        Return Previous.GetDirectory(virtualDir)
      End If
    End Function

    Public Overrides Function GetCacheDependency(ByVal virtualPath As String, ByVal virtualPathDependencies As IEnumerable, ByVal utcStart As Date) As CacheDependency
      If (IsPathVirtual(virtualPath)) Then

        Dim fullPathDependencies As System.Collections.Specialized.StringCollection
        fullPathDependencies = Nothing

        ' Get the full path to all dependencies.
        For Each virtualDependency As String In virtualPathDependencies
          If fullPathDependencies Is Nothing Then
            fullPathDependencies = New System.Collections.Specialized.StringCollection
          End If

          fullPathDependencies.Add(virtualDependency)
        Next

        If fullPathDependencies Is Nothing Then
          Return Nothing
        End If

        Dim fullPathDependenciesArray As String()
        fullPathDependencies.CopyTo(fullPathDependenciesArray, 0)

        Return New CacheDependency(fullPathDependenciesArray, utcStart)
      Else
        Return Previous.GetCacheDependency(virtualPath, virtualPathDependencies, utcStart)
      End If
    End Function
  End Class
End Namespace

第二个示例是用于填充自定义DataSet VirtualPathProvider对象返回的对象的 XML 数据文件。The second example is the XML data file used to populate the DataSet object returned by the custom VirtualPathProvider object. 此 XML 数据用于演示如何使用VirtualPathProviderVirtualDirectoryVirtualFile对象从外部数据中检索数据, 而不用于表示生产质量的数据存储区。This XML data is used to demonstrate using the VirtualPathProvider, VirtualDirectory, and VirtualFile objects to retrieve data from external data and is not intended to represent a production-quality data store.

<?xml version="1.0" encoding="utf-8" ?>  
  <resource type="dir"   
    path="/vrDir"   
    parentPath=""   
    content="">  
    <resource type="file"   
      path="/vrDir/Level1FileA.vrf"  
      parentPath="/vrDir"   
      content="This is the content of file Level1FileA.">  
    </resource>  
    <resource type="file"   
      path="/vrDir/Level1FileB.vrf"  
      parentPath="/vrDir"   
      content="This is the content of file Level1FileB.">  
    </resource>  
    <resource type="dir"   
      path="/vrDir/Level2DirA"   
      parentPath="/vrDir"   
      content="">  
    <resource type="file"   
      path="/vrDir/Level2DirA/Level2FileA.vrf"   
      parentPath="/vrDir/Level2DirA"   
      content="This is the content of file Level2FileA.">  
    </resource>  
    <resource type="file"   
      path="/vrDir/Level2DirA/Level2FileB.vrf"  
      parentPath="/vrDir/Level2DirA"   
      content="This is the content of file Level2FileB.">  
    </resource>  
  </resource>  
  <resource type="dir"   
    path="/vrDir/Level2DirB"   
    parentPath="/vrDir"   
    content="">  
    <resource type="file"   
      path="/vrDir/Level2DirB/Level2FileA.vrf"   
      parentPath="/vrDir/Level2DirB"   
      content="This is the content of file Level2FileA.">  
    </resource>  
    <resource type="file"   
      path="/vrDir/Level2DirB/Level2FileB.vrf"  
      parentPath="/vrDir/Level2DirB"   
      content="This is the content of file Level2FileB.">  
    </resource>  
  </resource>  
</resource>  

第三个示例提供AppStart一个AppInitialize包含方法的对象。The third example provides an AppStart object that contains an AppInitialize method. 此方法在 ASP.NET 应用程序的初始化过程中调用, 以执行所需的任何自定义初始化。This method is called during the initialization of an ASP.NET application to perform any custom initialization required. 在这种情况下, 它会VirtualPathProvider向 ASP.NET 生成系统注册自定义对象。In this case, it registers the custom VirtualPathProvider object with the ASP.NET build system.

using System.Web.Hosting;

namespace Samples.AspNet.CS
{
  /// <summary>
  ///   Contains the application initialization method
  ///   for the sample application.
  /// </summary>
  public static class AppStart
  {
    public static void AppInitialize()
    {
      SamplePathProvider sampleProvider = new SamplePathProvider();
      HostingEnvironment.RegisterVirtualPathProvider(sampleProvider);
    } 
  }
}

Imports System.Web.Hosting

Namespace Samples.AspNet.VB

  Public Class AppStart

    Public Shared Sub AppInitialize()
      Dim sampleProvider As SamplePathProvider = New SamplePathProvider()
      HostingEnvironment.RegisterVirtualPathProvider(sampleProvider)
    End Sub

  End Class
End Namespace

最后一个示例是一个 ASP.NET 页面, 其中包含指向虚拟文件系统中包含的虚拟文件的链接。The last example is an ASP.NET page that contains links to the virtual files contained in the virtual file system.


<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
  <meta http-equiv="Content-Type" content="text/html" />
  <title>Virtual Path Provider Example</title>
</head>
<body>
  <form id="form1" runat="server">
    <asp:HyperLink ID="hyperLink1" runat="server" NavigateUrl="vrDir/Level1FileA.vrf" Text="Level 1, File A" /><br />
    <asp:HyperLink ID="hyperLink2" runat="server" NavigateUrl="vrDir/Level1FileB.vrf" Text="Level 1, File B" /><br />
    <asp:HyperLink ID="hyperLink3" runat="server" NavigateUrl="vrDir/Level2DirA/Level2FileA.vrf" Text="Level 2a, File A" /><br />
    <asp:HyperLink ID="hyperLink4" runat="server" NavigateUrl="vrDir/Level2DirA/Level2FileB.vrf" Text="Level 2a, File B" /><br />
    <asp:HyperLink ID="hyperLink5" runat="server" NavigateUrl="vrDir/Level2DirB/Level2FileA.vrf" Text="Level 2b, File A" /><br />
    <asp:HyperLink ID="hyperLink6" runat="server" NavigateUrl="vrDir/Level2DirB/Level2FileB.vrf" Text="Level 2b, File B" /><br />
  </form>
</body>
</html>
<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
  <meta http-equiv="Content-Type" content="text/html" />
  <title>Virtual Path Provider Example</title>
</head>
<body>
  <form id="form1" runat="server">
    <asp:HyperLink ID="hyperLink1" runat="server" NavigateUrl="vrDir/Level1FileA.vrf" Text="Level 1, File A" /><br />
    <asp:HyperLink ID="hyperLink2" runat="server" NavigateUrl="vrDir/Level1FileB.vrf" Text="Level 1, File B" /><br />
    <asp:HyperLink ID="hyperLink3" runat="server" NavigateUrl="vrDir/Level2DirA/Level2FileA.vrf" Text="Level 2a, File A" /><br />
    <asp:HyperLink ID="hyperLink4" runat="server" NavigateUrl="vrDir/Level2DirA/Level2FileB.vrf" Text="Level 2a, File B" /><br />
    <asp:HyperLink ID="hyperLink5" runat="server" NavigateUrl="vrDir/Level2DirB/Level2FileA.vrf" Text="Level 2b, File A" /><br />
    <asp:HyperLink ID="hyperLink6" runat="server" NavigateUrl="vrDir/Level2DirB/Level2FileB.vrf" Text="Level 2b, File B" /><br />
  </form>
</body>
</html>

注解

VirtualPathProvider类提供一组方法, 用于实现 Web 应用程序的虚拟文件系统。The VirtualPathProvider class provides a set of methods for implementing a virtual file system for a Web application. 在虚拟文件系统中, 文件和目录由服务器操作系统所提供的文件系统以外的数据存储管理。In a virtual file system, the files and directories are managed by a data store other than the file system provided by the server's operating system. 例如, 可以使用虚拟文件系统将内容存储在 SQL Server 数据库中。For example, you can use a virtual file system to store content in a SQL Server database.

可以存储在虚拟文件系统中按请求处理的任何文件。You can store any file that is processed on request in a virtual file system. 这包括:This includes:

  • ASP.NET 页、母版页、用户控件和其他对象。ASP.NET pages, master pages, user controls, and other objects.

  • 扩展名为 .htm 和 .jpg 的标准网页。Standard Web pages with extensions such as .htm and .jpg.

  • 映射到实例的BuildProvider任何自定义扩展。Any custom extension mapped to a BuildProvider instance.

  • 文件夹中的App_Theme任何命名主题。Any named theme in the App_Theme folder.

不能将 ASP.NET 应用程序文件夹或文件存储在虚拟文件系统中。You cannot store ASP.NET application folders or files that generate application-level assemblies in a virtual file system. 这包括:This includes:

  • Global.asax 文件。The Global.asax file.

  • Web.config 文件。Web.config files.

  • 使用的站点地图数据文件XmlSiteMapProviderSite map data files used by the XmlSiteMapProvider.

  • 包含应用程序程序集或生成应用程序程序集BinApp_Code目录App_GlobalResources:、 App_LocalResources、、any。Directories that contain application assemblies or that generate application assemblies: Bin, App_Code, App_GlobalResources, any App_LocalResources.

  • 应用程序数据文件夹App_DataThe application data folder, App_Data.

备注

如果为部署预编译了某个网站, 则不会编译VirtualPathProvider实例提供的内容, 并且预VirtualPathProvider编译的站点不使用任何实例。If a Web site is precompiled for deployment, content provided by a VirtualPathProvider instance is not compiled, and no VirtualPathProvider instances are used by the precompiled site.

注册 VirtualPathProviderRegistering a VirtualPathProvider

自定义VirtualPathProvider实例应通过HostingEnvironment.RegisterVirtualPathProvider使用方法在 Web 应用程序执行任何页面分析或编译之前, 使用方法在 ASP.NET 编译系统中进行注册。A custom VirtualPathProvider instance should be registered with the ASP.NET compilation system by using the HostingEnvironment.RegisterVirtualPathProvider method before any page parsing or compilation is performed by the Web application.

通常情况下VirtualPathProvider , 会AppInitializeApp_Code 目录中Application_Start定义的方法中或在文件中的事件过程中注册实例。Global.asaxTypically, a VirtualPathProvider instance is registered in an AppInitialize method defined in the App_Code directory, or during the Application_Start event in the Global.asax file. VirtualPathProvider 有关AppInitialize在方法中注册实例的示例, 请参见 "示例" 部分。For an example of registering a VirtualPathProvider instance in an AppInitialize method, see the Example section.

你可以在其他VirtualPathProvider事件期间注册实例, 但在注册VirtualPathProvider实例之前编译和缓存的页面将不会失效, 即使新VirtualPathProvider实例现在将为之前的提供源提供已编译页面。You can register a VirtualPathProvider instance during other events, but pages compiled and cached before the VirtualPathProvider instance is registered will not be invalidated, even if the new VirtualPathProvider instance would now provide the source for the previously compiled page.

实施者说明

当从VirtualPathProvider继承时, 必须重写以下成员:When you inherit from VirtualPathProvider, you must override the following members:

如果自定义VirtualPathProvider类支持虚拟文件系统中的目录, 则必须重写以下成员。If your custom VirtualPathProvider class supports directories in the virtual file system, you must override the following members.

构造函数

VirtualPathProvider()

初始化该类供继承的类实例使用。Initializes the class for use by an inherited class instance. 此构造函数只能由继承的类调用。This constructor can be called only by an inherited class.

属性

Previous

获取对编译系统中以前注册的 VirtualPathProvider 对象的引用。Gets a reference to a previously registered VirtualPathProvider object in the compilation system.

方法

CombineVirtualPaths(String, String)

将基路径与相对路径组合,以返回某虚拟资源的完整路径。Combines a base path with a relative path to return a complete path to a virtual resource.

CreateObjRef(Type)

创建一个对象,该对象包含生成用于与远程对象进行通信的代理所需的全部相关信息。Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(继承自 MarshalByRefObject)
DirectoryExists(String)

获取一个值,该值指示目录是否存在于虚拟文件系统中。Gets a value that indicates whether a directory exists in the virtual file system.

Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
FileExists(String)

获取一个值,该值指示文件是否存在于虚拟文件系统中。Gets a value that indicates whether a file exists in the virtual file system.

GetCacheDependency(String, IEnumerable, DateTime)

基于指定的虚拟路径创建一个缓存依赖项。Creates a cache dependency based on the specified virtual paths.

GetCacheKey(String)

返回一个用于指定虚拟路径的缓存键。Returns a cache key to use for the specified virtual path.

GetDirectory(String)

从虚拟文件系统中获取一个虚拟目录。Gets a virtual directory from the virtual file system.

GetFile(String)

从虚拟文件系统中获取一个虚拟文件。Gets a virtual file from the virtual file system.

GetFileHash(String, IEnumerable)

返回指定虚拟路径的哈希值。Returns a hash of the specified virtual paths.

GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetLifetimeService()

检索控制此实例的生存期策略的当前生存期服务对象。Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(继承自 MarshalByRefObject)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
Initialize()

初始化 VirtualPathProvider 实例。Initializes the VirtualPathProvider instance.

InitializeLifetimeService()

通过阻止创建租约给予 VirtualPathProvider 对象无限的生存期。Gives the VirtualPathProvider object an infinite lifetime by preventing a lease from being created.

MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
MemberwiseClone(Boolean)

创建当前 MarshalByRefObject 对象的浅表副本。Creates a shallow copy of the current MarshalByRefObject object.

(继承自 MarshalByRefObject)
OpenFile(String)

从虚拟文件返回一个流。Returns a stream from a virtual file.

ToString()

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)

适用于