VirtualFile(String) 생성자

정의

VirtualFile 클래스의 새 인스턴스를 초기화합니다.

protected:
 VirtualFile(System::String ^ virtualPath);
protected VirtualFile (string virtualPath);
new System.Web.Hosting.VirtualFile : string -> System.Web.Hosting.VirtualFile
Protected Sub New (virtualPath As String)

매개 변수

virtualPath
String

이 인스턴스가 나타내는 리소스의 가상 경로입니다.

예제

다음 코드 예제는의 구현 합니다 VirtualFile 생성자에서 가상 파일 정보를 검색 하는 DataSet 사용자 지정에서 제공 하는 개체 VirtualPathProvider 개체입니다. 예제를 실행 하는 데 필요한 전체 코드의 예제 섹션을 참조 하세요.를 VirtualFile 클래스 개요입니다.

public SampleVirtualFile(string virtualPath, SamplePathProvider provider)
  : base(virtualPath)
{
  this.spp = provider;
  GetData();
}

protected void GetData()
{
  // Get the data from the SamplePathProvider
  DataSet ds = spp.GetVirtualData();

  // Get the virtual file from the resource table.
  DataTable files = ds.Tables["resource"];
  DataRow[] rows = files.Select(
    String.Format("(name = '{0}') AND (type='file')", this.Name));

  // If the select returned a row, store the file contents.
  if (rows.Length > 0)
  {
    DataRow row = rows[0];

    content = row["content"].ToString();
  }
}
Public Sub New(ByVal virtualPath As String, ByVal provider As SamplePathProvider)
  MyBase.New(virtualPath)
  spp = provider
  GetData()
End Sub

Protected Sub GetData()
  ' Get the data from the SamplePathProvider.
  Dim spp As SamplePathProvider
  spp = CType(HostingEnvironment.VirtualPathProvider, SamplePathProvider)

  Dim ds As DataSet
  ds = spp.GetVirtualData

  ' Get the virtual file data from the resource table.
  Dim files As DataTable
  files = ds.Tables("resource")

  Dim rows As DataRow()
  rows = files.Select( _
    String.Format("(name='{0}') AND (type='file')", Me.Name))

  ' If the select returned a row, store the file contents.
  If (rows.Length > 0) Then
    Dim row As DataRow
    row = rows(0)

    content = row("content").ToString()
  End If
End Sub

적용 대상