本文整理汇总了C#中System.IO.DirectoryInfo.EnumerateDirectories方法的典型用法代码示例。如果您正苦于以下问题:C# System.IO.DirectoryInfo.EnumerateDirectories方法的具体用法?C# System.IO.DirectoryInfo.EnumerateDirectories怎么用?C# System.IO.DirectoryInfo.EnumerateDirectories使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.DirectoryInfo
的用法示例。
在下文中一共展示了System.IO.DirectoryInfo.EnumerateDirectories方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReplayServer
public ReplayServer(MFroReplay replay)
{
this.replay = replay;
this.alive = true;
try {
server = new HttpListener();
server.Prefixes.Add("http://127.0.0.1:" + port + "/observer-mode/rest/consumer/");
server.Start();
} catch {
try { AddAddress("http://127.0.0.1:" + port + "/"); } catch { return; }
server = new HttpListener();
server.Prefixes.Add("http://127.0.0.1:" + port + "/observer-mode/rest/consumer/");
server.Start();
}
new Thread(this.Stopper) { IsBackground = true, Name = "Server Stopper" }.Start();
new Thread(() => {
Logger.WriteLine("Starting Spectator Server [ID: {0}]... ".Format(replay.GameId));
try {
while (alive) { Handle(server.GetContext()); }
} catch { }
server.Close();
Logger.WriteLine("Closing Spectator Server");
}) { IsBackground = true, Name = "ServerHandler" }.Start();
var dir = new System.IO.DirectoryInfo(@"C:\Riot Games\League of Legends\RADS\"
+ @"solutions\lol_game_client_sln\releases\");
var versions = dir.EnumerateDirectories().ToList();
versions.Sort((a, b) => b.Name.CompareTo(a.Name));
ProcessStartInfo info = new ProcessStartInfo(versions[0].FullName + @"\deploy\League of Legends.exe",
String.Join(" ", SpectateArgs).Format(replay.MetaData["encryptionKey"], replay.GameId));
info.WorkingDirectory = versions[0].FullName + @"\deploy";
Process.Start(info);
}
示例2: GetSelections
public IEnumerable<ISelectItem> GetSelections(ExtendedMetadata metadata)
{
var layoutDirectory = new System.IO.DirectoryInfo(HostingEnvironment.MapPath("~/Views/Shared/Layouts"));
if(!layoutDirectory.Exists)
{
yield return new SelectItem() { Text = "No layouts available.", Value = "" };
yield break;
}
var layouts = layoutDirectory.EnumerateDirectories("*", System.IO.SearchOption.TopDirectoryOnly);
var siteroot = System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath;
foreach(var s in layouts)
{
yield return new SelectItem()
{
Text = s.Name,
Value = s.FullName.Replace(siteroot, string.Empty).Replace("\\", "/").Insert(0,"~/")
};
}
}
示例3: AddFolder
private PackageFileSourceInfo AddFolder(PackageHeirarchyItem parent, string filePath)
{
PackageHeirarchyItem newItem = null;
System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(filePath);
if (parent != null && !Contains(parent, dir.Name))
{
newItem = new PackageHeirarchyItem(filePath);
newItem.Name = dir.Name;
newItem.Parent = parent;
parent.Children.Add(newItem);
// EnumerateFiles is not working on mono for some reason, therefore use GetFiles instead,
IEnumerable<System.IO.FileInfo> files;
if(TraceLabSDK.RuntimeInfo.IsRunInMono)
{
files = dir.GetFiles();
}
else
{
files = dir.EnumerateFiles();
}
foreach (System.IO.FileInfo file in files)
{
AddFile(newItem, file.FullName);
}
foreach (System.IO.DirectoryInfo subDir in dir.EnumerateDirectories())
{
AddFolder(newItem, subDir.FullName);
}
}
return newItem;
}
示例4: CheckPath
private static string CheckPath(string path, string name)
{
string ret="";
try
{
var di = new System.IO.DirectoryInfo(path);
di.EnumerateDirectories();
} catch(Exception e)
{
ret += name + " can't enumerate, error "+e.Message+"<br />";
}
if (!System.IO.Directory.Exists(path))
ret += name + " doesn't exist<br />";
if (!(path.EndsWith("/") || path.EndsWith("\\")))
ret += name + " should end with / or \\<br />";
return ret;
}
示例5: ThemeFolderList
/// <summary>
/// Returns a list of theme folders from the file system for selection
/// </summary>
/// <param name="clientId"></param>
/// <returns></returns>
public static IEnumerable<SelectListItem> ThemeFolderList(this HtmlHelper htmlHelper)
{
HttpServerUtilityBase server = htmlHelper.ViewContext.HttpContext.Server;
string virtualPath = "~/Content/Server/Themes/";
if (!System.IO.Directory.Exists(server.MapPath(virtualPath)))
{
throw new ApplicationException("Themes folder does not exist in file system at '" + virtualPath + "'");
}
System.IO.DirectoryInfo themesFolder = new System.IO.DirectoryInfo(server.MapPath(virtualPath));
IEnumerable<System.IO.DirectoryInfo> themeFolders = themesFolder.EnumerateDirectories("*", System.IO.SearchOption.TopDirectoryOnly);
string selectedName = htmlHelper.ViewData.Model as string;
return themeFolders.Select(t => new SelectListItem
{
Value = t.Name,
Text = t.Name + " [" + (System.IO.File.Exists(t.FullName + "\\bootstrap.min.css") ? "bootstrap.min.css OK" : "WARNING: no bootstrap.min.css") + "]",
Selected = t.Name == selectedName
});
}
示例6: CreateSeedThemes
/// <summary>
/// Dupe-safe uses theme.FolderName to prevent dupes
/// </summary>
private static List<Theme> CreateSeedThemes(this IGstoreDb storeDb, string virtualPath, Client client)
{
string path = string.Empty;
if (HttpContext.Current == null)
{
string assemblyPath = new Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).AbsolutePath;
string directoryName = System.IO.Path.GetDirectoryName(assemblyPath).Replace("GStore\\GStoreData\\", "GStore\\GStoreWeb\\");
path = System.IO.Path.Combine(directoryName, "..\\.." + virtualPath.TrimStart('~').Replace('/', '\\')).Replace("%20", " ");
if (!System.IO.Directory.Exists(path))
{
throw new ApplicationException("Themes folder could not be found in file system at path: " + path + ". Please run the web site first to populate the database.");
}
}
else
{
path = HttpContext.Current.Server.MapPath(virtualPath);
}
if (!System.IO.Directory.Exists(path))
{
throw new ApplicationException("Themes folder could not be found in file system web server at path: " + path + ".");
}
System.IO.DirectoryInfo themesFolder = new System.IO.DirectoryInfo(path);
IEnumerable<System.IO.DirectoryInfo> themeFolders = themesFolder.EnumerateDirectories();
int counter = 0;
List<Theme> newThemes = new List<Theme>();
foreach (System.IO.DirectoryInfo themeFolder in themeFolders)
{
if (!client.Themes.Any(t => t.FolderName.ToLower() == themeFolder.Name.ToLower()))
{
counter++;
Theme theme = storeDb.Themes.Create();
theme.Name = themeFolder.Name;
theme.Order = 2000 + counter;
theme.FolderName = themeFolder.Name;
theme.Description = themeFolder.Name + " theme";
theme.IsPending = false;
theme.StartDateTimeUtc = DateTime.UtcNow.AddMinutes(-1);
theme.EndDateTimeUtc = DateTime.UtcNow.AddYears(100);
theme.Client = client;
theme.ClientId = client.ClientId;
storeDb.Themes.Add(theme);
newThemes.Add(theme);
}
}
storeDb.SaveChangesEx(true, false, false, false);
return newThemes;
}