本文整理汇总了C#中System.IO.DirectoryInfo.GetFilesByExtensions方法的典型用法代码示例。如果您正苦于以下问题:C# DirectoryInfo.GetFilesByExtensions方法的具体用法?C# DirectoryInfo.GetFilesByExtensions怎么用?C# DirectoryInfo.GetFilesByExtensions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.DirectoryInfo
的用法示例。
在下文中一共展示了DirectoryInfo.GetFilesByExtensions方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetImages
public ActionResult GetImages()
{
var directory = new System.IO.DirectoryInfo(Server.MapPath("/Images/"));
string html = "<table>";
int i = 0;
foreach (var file in directory.GetFilesByExtensions(".png", ".gif", ".jpg"))
{
//if (file.Name == "Facebook.png" || file.Name == "down.gif" || file.Name == "github.png" || file.Name == "GitHubFooter.png" || file.Name == "leftedge.gif" || file.Name == "LinkedIn.png" || file.Name == "rightedge.gif" || file.Name == "turquoise-pattern.gif")
//{
// continue;
//}
if (i % 20 == 0)
{
html += "<tr><td><div class=\"thumbnail\"><img style=\"height:80px;width:80px;\" src=\"" + GetURL() + file.Name + "\"" + " alt=\"thumb\" title=\"" + GetURL() + file.Name + "\"/></div></td>";
}
else
{
html += "<td><div class=\"thumbnail\"><img style=\"height:80px;width:80px;\" src=\"" + GetURL() + file.Name + "\"" + " alt=\"thumb\" title=\"" + GetURL() + file.Name + "\"/></div></td>";
}
if (i == file.Length - 1)
{
html += "</table>";
}
i++;
}
return Content(html);
}
示例2: LoadSeries
public static Series LoadSeries(string path)
{
var dir = new DirectoryInfo(path);
var series = new Series { Name = dir.Name, Books = new List<Book>() };
foreach (var file in dir.GetFilesByExtensions(".cbr", ".cbz", ".zip", ".rar"))
{
var book = new Book {Name = Path.GetFileName(file.Name)};
if (book != null)
series.Books.Add(book);
}
return series;
}
示例3: ResourceFiles
public IEnumerable<ResourceFile> ResourceFiles()
{
try
{
DirectoryInfo dirInfo = new DirectoryInfo(resourcesDirectory);
var files = from file in dirInfo.GetFilesByExtensions(ResourceFile.AllowableResourceTypes)
select new ResourceFile(file.Name, TypeFrom(file.Extension), file.FullName);
return files;
}
catch (UnauthorizedAccessException UAEx)
{
throw UAEx;
}
catch (PathTooLongException PathEx)
{
throw PathEx;
}
}
示例4: FolderSelected
public void FolderSelected(string directory)
{
this.SelectedItemPath = directory;
DirectoryInfo dirInfo = new DirectoryInfo(directory);
var files = dirInfo.GetFilesByExtensions(".mp3", ".m4a");
this.Songs = new ObservableCollection<Song>(files.Select(f =>
{
TagLib.File file = TagLib.File.Create(f.FullName);
return new Song(file);
}));
}
示例5: populateFileList
private void populateFileList()
{
DirectoryInfo directoryInfo = new DirectoryInfo(settings.DefaultSearchPath);
IEnumerable<FileInfo> files = directoryInfo.GetFilesByExtensions(settings.Extensions.ToArray());
this.fileList = files.ToList<FileInfo>();
}
示例6: Main
public static void Main(string[] args)
{
//Zebra2Preset.GenerateClassFields(@"C:\Users\perivar.nerseth\Documents\My Projects\AudioVSTToolbox\PresetConverter\_SharedResources\Zebra2-Default Sylenth1 Template.h2p", @"C:\Users\perivar.nerseth\Documents\My Projects\AudioVSTToolbox\PresetConverter\_SharedResources\properties.cs");
//Zebra2Preset.GenerateWriteMethod(@"C:\Users\perivar.nerseth\Documents\My Projects\AudioVSTToolbox\PresetConverter\_SharedResources\Zebra2-Default Sylenth1 Template.h2p", @"C:\Users\perivar.nerseth\Documents\My Projects\AudioVSTToolbox\PresetConverter\_SharedResources\getpreset.cs");
bool processDirectory = false;
bool doProcessInitPresets = false;
bool doOutputSylenthPresetTextDump = false;
bool doDebug = false;
// Command line parsing
string presetInputFileOrDirectory = "";
string presetOutputFileDirectoryPath = "";
Arguments CommandLine = new Arguments(args);
if(CommandLine["in"] != null) {
presetInputFileOrDirectory = CommandLine["in"];
}
if(CommandLine["out"] != null) {
presetOutputFileDirectoryPath = CommandLine["out"];
}
if(CommandLine["init"] != null) {
doProcessInitPresets = true;
}
if(CommandLine["text"] != null) {
doOutputSylenthPresetTextDump = true;
}
if(CommandLine["debug"] != null) {
doDebug = true;
}
if (presetInputFileOrDirectory == "" || presetOutputFileDirectoryPath == "") {
PrintUsage();
return;
}
// Build preset file paths
string sylenthPresetDirString = "";
string sylenthPreset = "";
// check if input is file or directory
if (IOUtils.IsDirectory(presetInputFileOrDirectory)) {
sylenthPresetDirString = presetInputFileOrDirectory;
processDirectory = true;
} else {
sylenthPreset = presetInputFileOrDirectory;
processDirectory = false;
}
// define default sylenth template for Zebra2
string zebra2_Sylenth1_PresetTemplate = @"Zebra2-Default Sylenth1 Template.h2p";
IEnumerable<FileInfo> presetFiles;
if (processDirectory) {
// process directory
DirectoryInfo sylenthPresetDir = new DirectoryInfo(sylenthPresetDirString);
presetFiles = sylenthPresetDir.GetFilesByExtensions(".fxb", ".fxp");
Console.WriteLine("Processing {0} files in directory: '{1}' ...", presetFiles.Count(), sylenthPresetDir.Name);
IOUtils.LogMessageToFile(outputStatusLog, String.Format("Processing {0} files in directory: '{1}' ...", presetFiles.Count(), sylenthPresetDir.Name));
} else {
// process single preset
FileInfo sylenthPresetFile = new FileInfo(sylenthPreset);
presetFiles = new FileInfo[] { sylenthPresetFile };
Console.WriteLine("Processing preset file '{0}' ...", sylenthPresetFile.Name);
IOUtils.LogMessageToFile(outputStatusLog, String.Format("Processing preset file '{0}' ...", sylenthPresetFile.Name));
}
foreach (FileInfo presetFile in presetFiles) {
// read preset file
Sylenth1Preset sylenth1 = new Sylenth1Preset();
if (doDebug) sylenth1.logLevel = Sylenth1Preset.LogLevel.Debug;
if (sylenth1.Read(presetFile.FullName)) {
// Output a dump of the Sylenth1 Preset File
if (doOutputSylenthPresetTextDump) {
string outSylenthPresetTextDumpPath = Path.GetFileNameWithoutExtension(presetFile.Name) + "_Text.txt";
TextWriter tw = new StreamWriter(outSylenthPresetTextDumpPath);
tw.WriteLine(sylenth1);
tw.Close();
}
// define output dir
string outputDir = "";
if (presetFile.Name.EndsWith(".fxb")) {
outputDir = Path.Combine(presetOutputFileDirectoryPath, Path.GetFileNameWithoutExtension(presetFile.Name));
if (!Directory.Exists(outputDir)) {
Directory.CreateDirectory(outputDir);
}
} else {
outputDir = presetOutputFileDirectoryPath;
}
// and convert to zebra 2
List<Zebra2Preset> zebra2ConvertedList = sylenth1.ToZebra2Preset(zebra2_Sylenth1_PresetTemplate, doProcessInitPresets);
int count = 1;
foreach (Zebra2Preset zebra2Converted in zebra2ConvertedList) {
string presetName = StringUtils.MakeValidFileName(zebra2Converted.PresetName);
string zebraGeneratedPreset = Path.Combine(outputDir, String.Format("{0:000}_{1}.h2p", zebra2Converted.BankIndex, presetName));
//.........这里部分代码省略.........
示例7: LoadExistingScreenFiles
/// <summary>
/// Load existing screen shot files
/// </summary>
private void LoadExistingScreenFiles()
{
DirectoryInfo d = new DirectoryInfo(screenShotPath);
var files = d.GetFilesByExtensions(".png", ".jpg");
foreach (var f in files)
{
AddFile(f.FullName);
}
}