本文整理汇总了C#中System.Web.Hosting.VirtualDirectory.VirtualDirectory构造函数的典型用法代码示例。如果您正苦于以下问题:C# VirtualDirectory构造函数的具体用法?C# VirtualDirectory怎么用?C# VirtualDirectory使用的例子?那么恭喜您, 这里精选的构造函数代码示例或许可以为您提供帮助。您也可以进一步了解该构造函数所在类System.Web.Hosting.VirtualDirectory
的用法示例。
在下文中一共展示了VirtualDirectory构造函数的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SampleVirtualDirectory
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);
}
}
}
}