本文整理汇总了C#中System.IO.FileInfo.Where方法的典型用法代码示例。如果您正苦于以下问题:C# FileInfo.Where方法的具体用法?C# FileInfo.Where怎么用?C# FileInfo.Where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.FileInfo
的用法示例。
在下文中一共展示了FileInfo.Where方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: recuperaNomeDoArquivo
private static string recuperaNomeDoArquivo(string identificadorImagem, FileInfo[] arquivos)
{
var arquivosComIdentificador =
arquivos.Where(fi => fi.Name.Contains(identificadorImagem));
if (arquivosComIdentificador.ToList<FileInfo>().Count == 0) {
throw new Exception(String.Format(
"Nenhum arquivo com o identificador {0} no nome. Não consigo identificar qual deve receber os metadados.",
identificadorImagem));
}
if (arquivosComIdentificador.ToList<FileInfo>().Count > 1) {
throw new Exception(String.Format(
"Mais de um arquivo com o identificador {0} no nome. Não consigo identificar qual deve receber os metadados.",
identificadorImagem));
}
return arquivosComIdentificador.ToList<FileInfo>()[0].Name;
}
示例2: ShowFileParsingInfo
private static void ShowFileParsingInfo(ITextExtractor textExtractor, FileInfo[] files)
{
PrintFilesList("Found the following files:", files);
var timer = new Stopwatch();
timer.Start();
var parsableFiles = files.Where(f => textExtractor.IsParseable(f.FullName)).ToArray();
timer.Stop();
Console.WriteLine("{0}{0}Processed in {1}{0}{0}", Environment.NewLine, timer.Elapsed);
PrintFilesList("Parsable files:", parsableFiles);
var unparsableFiles = files.Where(f => textExtractor.IsParseable(f.FullName) == false).ToArray();
PrintFilesList("Unparsable files:", unparsableFiles);
}
示例3: CompileWMSETfile
private void CompileWMSETfile(FileInfo[] sections, string countyLiteral)
{
byte[] buffer = new byte [sections.Sum(fi => (int) fi.Length) + 49*4];
uint[] sizes = new uint[48];
for (int i = 1; i <= 48; i++)
{
int i1 = i;
FileInfo[] f =
sections.Where(a => Path.GetFileName(a.FullName) == $"wmset{countyLiteral}.Section{i1}").ToArray();
sizes[i - 1] = (uint) f[0].Length;
uint globalLocation = 49*4;
for (int k = 0; k != i-1; k++)
globalLocation += sizes[k];
byte[] temp = BitConverter.GetBytes(globalLocation);
Array.Copy(temp, 0, buffer,(i-1)*4, 4);
temp = File.ReadAllBytes(f[0].FullName);
Array.Copy(temp, 0, buffer, globalLocation, temp.Length);
}
SaveFileDialog sfd = new SaveFileDialog
{
Filter = $"wmset{countyLiteral}.obj|wmset{countyLiteral}.obj",
Title = $"Save compiled wmset{countyLiteral} file!"
};
if (sfd.ShowDialog() == DialogResult.OK) File.WriteAllBytes(sfd.FileName, buffer);
else return;
Console.WriteLine($"WMSET: Succesfully saved {sfd.FileName} file");
}