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


C# System.IO.DirectoryInfo.EnumerateFiles方法代码示例

本文整理汇总了C#中System.IO.DirectoryInfo.EnumerateFiles方法的典型用法代码示例。如果您正苦于以下问题:C# System.IO.DirectoryInfo.EnumerateFiles方法的具体用法?C# System.IO.DirectoryInfo.EnumerateFiles怎么用?C# System.IO.DirectoryInfo.EnumerateFiles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IO.DirectoryInfo的用法示例。


在下文中一共展示了System.IO.DirectoryInfo.EnumerateFiles方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HasTestData

		public void HasTestData()
		{
			System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(TestFolder);

			var files = dir.EnumerateFiles();

			Assert.NotEmpty(files);
		}
开发者ID:clarkis117,项目名称:GenericMvcUtilities,代码行数:8,代码来源:FileRepoTests.cs

示例2: ApiWrapperWithLogger

 static ApiWrapperWithLogger()
 {
     exeDir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
     logDir = new System.IO.DirectoryInfo(exeDir + "\\NetworkLogs");
     if (logDir.Exists == false)
         logDir.Create();
     else
         foreach (var item in logDir.EnumerateFiles())
             item.Delete();
 }
开发者ID:namoshika,项目名称:SnkLib.Web.GooglePlus,代码行数:10,代码来源:ApiWrapperWithLogger.cs

示例3: Main

        static void Main(string[] args)
        {
            //Works fine
            System.IO.DirectoryInfo sysDirectory = new System.IO.DirectoryInfo("C:\\TEST");
            sysDirectory.EnumerateFiles();

            //Does not compile:
            //'Pri.LongPath.DirectoryInfo' does not contain a definition for 'EnumerateFiles'
            //and no extension method 'EnumerateFiles' accepting a first argument of type
            //'Pri.LongPath.DirectoryInfo' could be found (are you missing a using directive or an assembly reference?)
            Pri.LongPath.DirectoryInfo longDirectory = new Pri.LongPath.DirectoryInfo("C:\\TEST");
            longDirectory.EnumerateFiles();
        }
开发者ID:FuchsiaSoft,项目名称:LongPathTest,代码行数:13,代码来源:Program.cs

示例4: AddFolder

        private PackageFileSourceInfo AddFolder(PackageHeirarchyItem parent, string filePath)
        {
            PackageHeirarchyItem newItem = null;

            System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(filePath);
            if (parent != null && !Contains(parent, dir.Name))
            {
                newItem = new PackageHeirarchyItem(filePath);
                newItem.Name = dir.Name;
                newItem.Parent = parent;

                parent.Children.Add(newItem);

                // EnumerateFiles is not working on mono for some reason, therefore use GetFiles instead,
                IEnumerable<System.IO.FileInfo> files;
                if(TraceLabSDK.RuntimeInfo.IsRunInMono) 
                {
                    files = dir.GetFiles();
                } 
                else 
                {
                    files = dir.EnumerateFiles();
                }

                foreach (System.IO.FileInfo file in files)
                {
                    AddFile(newItem, file.FullName);
                }

                foreach (System.IO.DirectoryInfo subDir in dir.EnumerateDirectories())
                {
                    AddFolder(newItem, subDir.FullName);
                }
            }

            return newItem;
        }
开发者ID:CoEST,项目名称:TraceLab,代码行数:37,代码来源:PackageBuilderViewModel.cs

示例5: loadImages

        private void loadImages()
        {
            FolderBrowserDialog browser = new FolderBrowserDialog();
            DialogResult result;
            do{
                result = browser.ShowDialog();
            }while(result != DialogResult.OK);

            System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(browser.SelectedPath);
            IEnumerable<System.IO.FileInfo> files = dir.EnumerateFiles();
            IEnumerator<System.IO.FileInfo> fileEnumer = files.GetEnumerator();
            while (fileEnumer.MoveNext())
            {
                System.IO.FileInfo file = fileEnumer.Current;
                if (file.Extension == ".gif")
                {
                    Image img = Image.FromFile(file.FullName);
                    int capacity = images.Capacity;
                    images.Add(img);
                }
            }
            loaded = true;
            iterator = images.GetEnumerator();
        }
开发者ID:Vegemash,项目名称:GiffWall,代码行数:24,代码来源:Form1.cs

示例6: CreateSeedPageTemplates

        /// <summary>
        /// Dupe-safe uses PageTemplate.ViewName to prevent dupes
        /// </summary>
        private static List<PageTemplate> CreateSeedPageTemplates(this IGstoreDb storeDb, string virtualPath, Client client)
        {
            if (storeDb == null)
            {
                throw new ArgumentNullException("db");
            }
            if (string.IsNullOrEmpty(virtualPath))
            {
                throw new ArgumentNullException("virtualPath");
            }
            if (client == null)
            {
                throw new ArgumentNullException("client");
            }

            string path = string.Empty;
            if (HttpContext.Current == null)
            {
                string assemblyPath = new Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).AbsolutePath;
                string directoryName = System.IO.Path.GetDirectoryName(assemblyPath).Replace("GStore\\GStoreData\\", "GStore\\GStoreWeb\\");
                path = System.IO.Path.Combine(directoryName, "..\\.." + virtualPath.TrimStart('~').Replace('/', '\\')).Replace("%20", " ");
                if (!System.IO.Directory.Exists(path))
                {
                    throw new ApplicationException("Page Templates folder could not be found in file system at path: " + path + ". Please run the web site first to populate the database.");
                }
            }
            else
            {
                path = HttpContext.Current.Server.MapPath(virtualPath);
            }

            if (!System.IO.Directory.Exists(path))
            {
                throw new ApplicationException("Page Templates folder could not be found in file system web server at path: " + path + ".");
            }

            System.IO.DirectoryInfo folder = new System.IO.DirectoryInfo(path);
            IEnumerable<System.IO.FileInfo> files = folder.EnumerateFiles("Page *.cshtml");
            int counter = 0;
            List<PageTemplate> newTemplates = new List<PageTemplate>();
            foreach (System.IO.FileInfo file in files)
            {
                string name = file.Name.Substring(5, ((file.Name.Length - 5) - 7)) + " Template";
                if (!client.PageTemplates.Any(pt => pt.Name.ToLower() == name.ToLower()))
                {
                    string viewName = file.Name.Replace(".cshtml", "");
                    if (!client.PageTemplates.Any(pt => pt.ViewName.ToLower() == viewName.ToLower()))
                    {
                        counter++;
                        PageTemplate pageTemplate = storeDb.PageTemplates.Create();
                        pageTemplate.Name = name;
                        pageTemplate.ViewName = viewName;
                        pageTemplate.Order = 2000 + counter;
                        if (name.ToLower() == "custom html page template")
                        {
                            pageTemplate.Order = 9000 + counter;
                        }
                        pageTemplate.Description = pageTemplate.Name;
                        pageTemplate.IsPending = false;
                        pageTemplate.StartDateTimeUtc = DateTime.UtcNow.AddMinutes(-1);
                        pageTemplate.EndDateTimeUtc = DateTime.UtcNow.AddYears(100);
                        pageTemplate.Client = client;
                        pageTemplate.ClientId = client.ClientId;

                        storeDb.PageTemplates.Add(pageTemplate);
                        newTemplates.Add(pageTemplate);
                    }
                }

            }
            storeDb.SaveChangesEx(true, false, false, false);

            return newTemplates;
        }
开发者ID:berlstone,项目名称:GStore,代码行数:77,代码来源:SeedDataExtensions.cs

示例7: Load

        public static FilmBox Load(FilmSession filmSession, string filmBoxFolder)
        {
            var filmBoxFile = string.Format(@"{0}\FilmBox.dcm", filmBoxFolder);

            var file = DicomFile.Open(filmBoxFile);
            

            var filmBox = new FilmBox(filmSession, file.FileMetaInfo.MediaStorageSOPInstanceUID, file.Dataset);

            var imagesFolder = new System.IO.DirectoryInfo(string.Format(@"{0}\Images", filmBoxFolder));
            foreach (var image in imagesFolder.EnumerateFiles("*.dcm"))
            {
                var imageBox = ImageBox.Load(filmBox, image.FullName);

                filmBox.BasicImageBoxes.Add(imageBox);
            }
            return filmBox;
        }
开发者ID:dremerdt,项目名称:fo-dicom,代码行数:18,代码来源:FilmBox.cs

示例8: GetInputVectors

        private void GetInputVectors()
        {
            if (_appSettings.imageDirectory == "")
            {
                return;
            }

            _appSettings.images.Clear();

            // Get image files by filtering by extensions
            System.IO.DirectoryInfo directoryInfo = new System.IO.DirectoryInfo(_appSettings.imageDirectory);
            string[] extensions = new string[] { ".bmp", ".jpg", ".png", ".gif" };
            var allowedExtensions = new HashSet<string>(extensions, StringComparer.OrdinalIgnoreCase);
            System.IO.FileInfo[] fileInfos = directoryInfo
                .EnumerateFiles("*", System.IO.SearchOption.AllDirectories)
                .Where(f => allowedExtensions.Contains(f.Extension)).ToArray();

            foreach (System.IO.FileInfo f in fileInfos)
            {
                using (Bitmap img = new Bitmap(f.FullName))
                {
                    try
                    {
                        // Feature Extraction
                        ImageData imgData = PictureSOM.SOMHelper.GetImageData(img);
                        imgData.m_fileName = f.Name;
                        imgData.m_directoryName = f.DirectoryName;
                        Console.WriteLine(imgData.m_fullName);

                        // Test experimental features here
                        //float[] testFeature = Features.calculateCEDD_Compact(img);

                        _appSettings.images.Add(imgData);
                    }
                    catch(Exception)
                    {
                        Console.WriteLine("Could not add " + f.FullName);
                    }

                }
            }
        }
开发者ID:pyephyomaung,项目名称:som-ar,代码行数:42,代码来源:MainWindow.xaml.cs


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