VirtualDirectory コンストラクタとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > VirtualDirectory コンストラクタの意味・解説 

VirtualDirectory コンストラクタ

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

VirtualDirectory クラス新しインスタンス初期化します。

名前空間: System.Web.Hosting
アセンブリ: System.Web (system.web.dll 内)
構文構文

Protected Sub New ( _
    virtualPath As String _
)
Dim virtualPath As String

Dim instance As New VirtualDirectory(virtualPath)
protected VirtualDirectory (
    string virtualPath
)
protected:
VirtualDirectory (
    String^ virtualPath
)
protected VirtualDirectory (
    String virtualPath
)
protected function VirtualDirectory (
    virtualPath : String
)

パラメータ

virtualPath

このインスタンスによって表されるリソースへの仮想パス

使用例使用例

VirtualPathProvider カスタム オブジェクトによって提供されDataSet オブジェクトから仮想ファイル情報取得する VirtualDirectory コンストラクタ実装例次のコード示します。この例には、VirtualDirectory インスタンス設定使用されるGetData メソッド含まれています。例の実行必要なコード全体については、VirtualDirectory クラス概要で「例」を参照してください

Public Sub New(ByVal
 virtualDir As String, ByVal
 provider As SamplePathProvider)
  MyBase.New(virtualDir)
  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

  ' Clean up the path to match data in resource file.
  Dim path As String
  path = VirtualPath.Replace(HostingEnvironment.ApplicationVirtualPath, "")
  Dim trimChars() As Char
 = {"/"c}
  path = path.TrimEnd(trimChars)

  ' Get the virtual directory from the resource table.
  Dim dirs As DataTable
  dirs = ds.Tables("resource")
  Dim rows As DataRow()
  rows = dirs.Select( _
    String.Format("(name = '{0}') AND (type='dir')",
 path))

  ' If the select returned a row, the directory exits.
  If (rows.Length > 0) Then
    existsValue = True

    ' Get the children from the resource table.
    ' This technique works for small numbers of virtual resources.
    '  Sites with moderate to large numbers of virtual
    '  resources should choose a method that consumes fewer
    '  computer resources.
    Dim childRows As DataRow()
    childRows = dirs.Select( _
      String.Format("parentPath = '{0}'",
 path))

    For Each childRow As
 DataRow In childRows
      Dim childPath As String
      childPath = CType(childRow("path"), String)

      If (childRow("type").ToString
 = "dir") Then
        Dim svd As New SampleVirtualDirectory(childPath,
 spp)
        childrenValue.Add(svd)
        directoriesValue.Add(svd)
      Else
        Dim svf As New SampleVirtualFile(childPath,
 spp)
        childrenValue.Add(svf)
        directoriesValue.Add(svf)
      End If
    Next

  End If
End Sub
public SampleVirtualDirectory(string virtualDir,
 SamplePathProvider provider)
  : base(virtualDir)
{
  spp = provider;
  GetData();
}

protected void GetData()
{
  DataSet ds = spp.GetVirtualData();

  // Clean up the path to match data in resource file.
  string path = VirtualPath.Replace(HostingEnvironment.ApplicationVirtualPath,
 "");
  path = path.TrimEnd('/');

  // Get the virtual directory from the resource table.
  DataTable dirs = ds.Tables["resource"];
  DataRow[] rows = dirs.Select(
    String.Format("(name = '{0}') AND (type='dir')", path));

  // If the select returned a row, the directory exists.
  if (rows.Length > 0)
  {
    exists = true;

    // Get children from the resource table.
    // This technique works for small numbers of virtual resources.
    //   Sites with moderate to large numbers of virtual
    //   resources should choose a method that consumes fewer
    //   computer resources.
    DataRow[] childRows = dirs.Select(
      String.Format("parentPath = '{0}'", path));

    foreach (DataRow childRow in childRows)
    {
      string childPath = (string)childRow["path"];

      if (childRow["type"].ToString() == "dir")
      {
        SampleVirtualDirectory svd = new SampleVirtualDirectory(childPath,
 spp);
        children.Add(svd);
        directories.Add(svd);
      }
      else
      {
        SampleVirtualFile svf = new SampleVirtualFile(childPath,
 spp);
        children.Add(svf);
        files.Add(svf);
      }
    }
  }
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
VirtualDirectory クラス
VirtualDirectory メンバ
System.Web.Hosting 名前空間



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「VirtualDirectory コンストラクタ」の関連用語

VirtualDirectory コンストラクタのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



VirtualDirectory コンストラクタのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS