Home > Net >  Consult the FileInfo under [] allFile add multiple formats
Consult the FileInfo under [] allFile add multiple formats

Time:10-10

The FileInfo [] allFile=dir. GetFiles (" *. De2 ");

Do I add a de4 format file to how to write?

CodePudding user response:

The FileInfo [] allFile=dir. GetFiles (" *. De2; *. De4 ");//it is also possible that | symbol segmentation, I don't remember clearly, you can check the MSDN ourselves, also can try me first
the two symbols

CodePudding user response:

reference 1/f, fat uncle write code reply:
the FileInfo [] allFile=dir. GetFiles (" *. De2; *. De4 ");//it is also possible that | symbol segmentation, I don't remember clearly, you can check the MSDN ourselves, also can try me first the two symbols

Can't seem to break up,

CodePudding user response:

System. IO. Directory. GetFiles (" c: \ ", "(*. Exe | *. TXT)");

CodePudding user response:

Oh, still can't believe I was wrong, baidu

The need to use linq,
Can be a var files=dinfo. GetFiles (" *.jpg ")
Concat (dinfo. GetFiles (" *. Tiff "))
Concat (dinfo. GetFiles (" *. BMP "));
This

Can also be getfiles (). The where

CodePudding user response:

https://codedefault.com/s/how-do-i-call-directory-getfiles-with-multiple-filters-in-csharp-application

CodePudding user response:

reference 4 floor wanghui0380 response:
oh, still can't believe I was wrong, baidu

The need to use linq,
Can be a var files=dinfo. GetFiles (" *.jpg ")
Concat (dinfo. GetFiles (" *. Tiff "))
Concat (dinfo. GetFiles (" *. BMP "));
This

Can also be getfiles (). The where



Public class DirectoryAllFiles
{
The static List The FileList=new List (a);
Public static List GetAllFiles DirectoryInfo (dir)
{
The FileInfo [] allFile=dir. GetFiles (" *. De4 ");
The foreach (the FileInfo fi in allFile)
{
FileList. Add (new FileInformation {FileName=fi. Name, FilePath=fi.. FullName});
}
DirectoryInfo [] allDir=dir. GetDirectories ();
The foreach (DirectoryInfo d in allDir)
{
GetAllFiles (d);
}
Return the FileList;
}
}
My code is that how to apply this method?

CodePudding user response:

https://docs.microsoft.com/zh-cn/dotnet/api/system.io.directory.getfiles? View=netframework 4.8

Yes, look at the Microsoft data searchPattern merger does not support multiple parameters, so only found out after array to merge, respectively

As for you to use linq or usually add or addrage operating this see you an array of familiarity, can not see the array operation document:
https://docs.microsoft.com/zh-cn/dotnet/api/system.array? View=netframework 4.8

CodePudding user response:

https://docs.microsoft.com/zh-cn/dotnet/api/system.collections.generic.ienumerable-1? View=netframework 4.8

CodePudding user response:

 
Dir. GetFiles (*. "DE *");
  •  Tags:  
  • C#
  • Related