當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。