当前位置: 首页>>代码示例>>C#>>正文


C# DirectoryInfo.GetFilesByExtensions方法代码示例

本文整理汇总了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);
        }
开发者ID:eplugplay,项目名称:LockSystemBusiness,代码行数:29,代码来源:FileBrowserController.cs

示例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;
        }
开发者ID:lluk,项目名称:Cromic,代码行数:15,代码来源:BookLoader.cs

示例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;
            }
        }
开发者ID:ramgp,项目名称:softedule,代码行数:20,代码来源:FilesService.cs

示例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);
                }));
        }
开发者ID:gotmug,项目名称:WorkoutMusic,代码行数:12,代码来源:MainWindowVM.cs

示例5: populateFileList

 private void populateFileList()
 {
     DirectoryInfo directoryInfo = new DirectoryInfo(settings.DefaultSearchPath);
     IEnumerable<FileInfo> files = directoryInfo.GetFilesByExtensions(settings.Extensions.ToArray());
     this.fileList = files.ToList<FileInfo>();
 }
开发者ID:shadowfox,项目名称:pvr-converter,代码行数:6,代码来源:MainForm.cs

示例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));
//.........这里部分代码省略.........
开发者ID:remy22,项目名称:AudioVSTToolbox,代码行数:101,代码来源:Program.cs

示例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);
     }
 }
开发者ID:broliver,项目名称:LabLauncher,代码行数:12,代码来源:ConsoleForm.cs


注:本文中的System.IO.DirectoryInfo.GetFilesByExtensions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。