本文整理汇总了C#中IDirectory.GetDirectories方法的典型用法代码示例。如果您正苦于以下问题:C# IDirectory.GetDirectories方法的具体用法?C# IDirectory.GetDirectories怎么用?C# IDirectory.GetDirectories使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDirectory
的用法示例。
在下文中一共展示了IDirectory.GetDirectories方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnFileRequested
/// <summary>
/// Called when the file is requested by a client.
/// </summary>
/// <param name="request">The <see cref="HttpRequest"/> requesting the file.</param>
/// <param name="directory">The <see cref="IDirectory"/> of the parent directory.</param>
public void OnFileRequested(HttpRequest request, IDirectory directory)
{
ICollection dirs;
ICollection files;
try
{
dirs = directory.GetDirectories();
files = directory.GetFiles();
}
catch(UnauthorizedAccessException)
{
throw new HttpRequestException("403");
}
request.Response.BeginChunkedOutput();
StreamWriter writer = new StreamWriter(request.Response.ResponseContent);
writer.WriteLine("<html>");
writer.WriteLine("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">");
writer.WriteLine("<head><title>Index of " + HttpWebServer.GetDirectoryPath(directory) + "</title></head>");
writer.WriteLine("<body>");
PrintBody(writer, request, directory, dirs, files);
writer.WriteLine("<hr>" + request.Server.ServerName);
writer.WriteLine("</body></html>");
writer.WriteLine("</body>");
writer.WriteLine("</html>");
writer.Flush();
}
示例2: Run
private static void Run(IDirectory directory)
{
foreach (var file in directory.GetFiles())
{
if (file.Name.EndsWith(".aspx", StringComparison.CurrentCultureIgnoreCase)
|| file.Name.EndsWith(".ascx", StringComparison.CurrentCultureIgnoreCase))
{
ReplaceLegacyControlTags(file);
}
}
foreach (var dir in directory.GetDirectories())
{
Run(dir);
}
}
示例3: createDirectoriesAndFiles
private void createDirectoriesAndFiles(IDirectory sourceDirectory, IDirectory destinationDirectory, string name)
{
IDirectory destDir;
if (name == null)
destDir = destinationDirectory.CreateSubdirectory(sourceDirectory.Name);
else
destDir = destinationDirectory.CreateSubdirectory(name);
foreach (var dir in sourceDirectory.GetDirectories())
{
createDirectoriesAndFiles(dir, destDir, null);
}
foreach (var file in sourceDirectory.GetFiles())
{
destDir.CreateFile(file);
}
}
示例4: FileCount
/// <summary>
/// Performs a recursive FileCount of the given directory (and it's descendents)
/// </summary>
/// <param name="directory"></param>
/// <returns></returns>
private int FileCount(IDirectory directory)
{
int count = directory.GetFiles().Count;
// Iterate the child directories
foreach (IDirectory childDirectory in directory.GetDirectories())
{
count += FileCount(childDirectory);
}
return count;
}
示例5: Run
private static void Run(IDirectory directory)
{
foreach (var file in directory.GetFiles())
{
if (file.Name.EndsWith(".aspx", StringComparison.CurrentCultureIgnoreCase)
|| file.Name.EndsWith(".ascx", StringComparison.CurrentCultureIgnoreCase))
{
var contents = file.Contents;
string newContent = GetUpgradedSkinFileContents(contents);
if (contents != newContent)
{
using (var stream = new StreamWriter(file.OpenWrite()))
{
stream.Write(newContent);
stream.Close();
}
}
}
}
foreach (var dir in directory.GetDirectories())
{
Run(dir);
}
}
示例6: BuildStructureFromFilePath
private IList<IExplorerItem> BuildStructureFromFilePath(IDirectory directory, string path, string rootPath)
{
var firstGen =
directory.GetDirectories(path)
.Where(a => !a.EndsWith("VersionControl"));
IList<IExplorerItem> children = new List<IExplorerItem>();
foreach(var resource in firstGen)
{
var resourcePath = resource.Replace(rootPath, "").Substring(1);
var node = new ServerExplorerItem(new DirectoryInfo(resource).Name, Guid.NewGuid(), ResourceType.Folder, null, _authService.GetResourcePermissions(Guid.Empty), resourcePath);
children.Add(node);
node.Children = BuildStructureFromFilePath(directory, resource, rootPath);
}
return children;
}
示例7: findManifest
private List<LocalTempList> findManifest(IDirectory rootDir)
{
var tempLocalList = new List<LocalTempList>();
//"Manifest.xml"
var file = rootDir.GetFiles(_manifestFileName).FirstOrDefault();
if (file != null)
{
//Create the temp manifest file
var localFileName = _localTempStorage.SaveManifest(file.GetBytes());
tempLocalList.Add(new LocalTempList() { LocalPath = localFileName, PackageStorePath = file.FullName });
Console.WriteLine("Found app at path: {0}", file.FullName);
}
else
{
foreach (var dir in rootDir.GetDirectories())
{
tempLocalList.AddRange(findManifest(dir));
}
}
return tempLocalList;
}