本文整理汇总了C#中System.IO.DirectoryInfo.Select方法的典型用法代码示例。如果您正苦于以下问题:C# System.IO.DirectoryInfo.Select方法的具体用法?C# System.IO.DirectoryInfo.Select怎么用?C# System.IO.DirectoryInfo.Select使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.DirectoryInfo
的用法示例。
在下文中一共展示了System.IO.DirectoryInfo.Select方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ErrorLog
public ActionResult ErrorLog(string log)
{
var logs = new System.IO.DirectoryInfo(Server.MapPath("~/App_Data")).GetFiles("*.log")
.OrderByDescending(o => o.LastWriteTime)
.Take(10)
.ToDictionary(f => f.Name, f => f.FullName);
string[] selected = { "Select a log file to view..." };
if (!string.IsNullOrWhiteSpace(log))
{
var file = logs.Where(l => l.Key == log).FirstOrDefault();
selected = System.IO.File.ReadAllLines(file.Value);
}
ErrorLogModel model = new ErrorLogModel() {
LogFiles = logs.Select(l => l.Key).ToArray(),
SelectedLog = selected
};
return View("ErrorLog", model);
}
示例2: LoadChars
private void LoadChars()
{
int maxCharacters = 16;
float initX = -9;
float initY = 15;
float deltaX = 7;
float deltaY = -7;
Vector2 pos = new Vector2(initX, initY);
var sortedFileInfos = new System.IO.DirectoryInfo(Path.Save).GetFiles().OrderBy(file => file.CreationTime).ToArray();
string[] sortedFiles = sortedFileInfos.Select(file => file.FullName).ToArray();
for (int i = 0; i < sortedFiles.Length && i < maxCharacters; i++)
{
zChars.Add(new MenuCharacter(sortedFiles[i]));
zChars.Last().Position = pos;
//get next pos
pos.X += deltaX;
if ((i+1) % 4 == 0)
{
pos.X = initX;
pos.Y += deltaY;
}
}
}