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


C# IDirectory.GetFiles方法代码示例

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


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

示例1: OnFileRequested

		/// <summary>
		/// Called when the file is requested by a client.
		/// </summary>
		/// <param name="request">The <see cref="HttpRequest"/> requesting the file.</param>
		/// <param name="directory">The <see cref="IDirectory"/> of the parent directory.</param>
		public void OnFileRequested(HttpRequest request, IDirectory directory)
		{
			ICollection dirs;
			ICollection files;
			try
			{
				dirs = directory.GetDirectories();
				files = directory.GetFiles();
			}
			catch(UnauthorizedAccessException)
			{
				throw new HttpRequestException("403");
			}

			request.Response.BeginChunkedOutput();
			StreamWriter writer = new StreamWriter(request.Response.ResponseContent);

			writer.WriteLine("<html>");
			writer.WriteLine("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">");
			writer.WriteLine("<head><title>Index of " + HttpWebServer.GetDirectoryPath(directory) + "</title></head>");
			writer.WriteLine("<body>");

			PrintBody(writer, request, directory, dirs, files);
			
			writer.WriteLine("<hr>" + request.Server.ServerName);
			writer.WriteLine("</body></html>");

			writer.WriteLine("</body>");
			writer.WriteLine("</html>");
			writer.Flush();
		}
开发者ID:GotenXiao,项目名称:blink1,代码行数:36,代码来源:IndexPage.cs

示例2: FindFiles

 /// <summary>
 /// Searches the given directory for files matching the search parameters of this object.
 /// </summary>
 /// <param name="directory">The directory to search.</param>
 /// <returns>A collection of files.</returns>
 public IEnumerable<IFile> FindFiles(IDirectory directory)
 {
     return from pattern in GetFilePatterns()
            from file in directory.GetFiles(pattern, SearchOption)
            where IsAssetFile(file)
            select file;
 }
开发者ID:JamesTryand,项目名称:cassette,代码行数:12,代码来源:FileSearch.cs

示例3: FindFiles

        /// <summary>
        /// Searches the given directory for files matching the search parameters of this object.
        /// </summary>
        /// <param name="directory">The directory to search.</param>
        /// <returns>A collection of files.</returns>
        public IEnumerable<IFile> FindFiles(IDirectory directory)
        {
            var files =
                from pattern in GetFilePatterns()
                from file in directory.GetFiles(pattern, SearchOption)
                where IsAssetFile(file)
                select file;

            return RemoveMinifiedFilesWhereNonMinExist(files);
        }
开发者ID:stucampbell,项目名称:cassette,代码行数:15,代码来源:FileSearch.cs

示例4: Run

 private static void Run(IDirectory directory)
 {
     foreach (var file in directory.GetFiles())
     {
         if (file.Name.EndsWith(".aspx", StringComparison.CurrentCultureIgnoreCase)
             || file.Name.EndsWith(".ascx", StringComparison.CurrentCultureIgnoreCase))
         {
             ReplaceLegacyControlTags(file);
         }
     }
     foreach (var dir in directory.GetDirectories())
     {
         Run(dir);
     }
 }
开发者ID:ChrisPelatari,项目名称:SubText,代码行数:15,代码来源:SkinUpgrader.cs

示例5: Run

 private static void Run(IDirectory directory)
 {
     foreach (var file in directory.GetFiles())
     {
         if (file.Name.EndsWith(".aspx", StringComparison.CurrentCultureIgnoreCase)
             || file.Name.EndsWith(".ascx", StringComparison.CurrentCultureIgnoreCase))
         {
             var contents = file.Contents;
             string newContent = GetUpgradedSkinFileContents(contents);
             if (contents != newContent)
             {
                 using (var stream = new StreamWriter(file.OpenWrite()))
                 {
                     stream.Write(newContent);
                     stream.Close();
                 }
             }
         }
     }
     foreach (var dir in directory.GetDirectories())
     {
         Run(dir);
     }
 }
开发者ID:rhoadsce,项目名称:Subtext,代码行数:24,代码来源:SkinUpgrader.cs

示例6: FileCount

        /// <summary>
        /// Performs a recursive FileCount of the given directory (and it's descendents)
        /// </summary>
        /// <param name="directory"></param>
        /// <returns></returns>
        private int FileCount(IDirectory directory)
        {
            int count = directory.GetFiles().Count;

            // Iterate the child directories
            foreach (IDirectory childDirectory in directory.GetDirectories())
            {
                count += FileCount(childDirectory);
            }

            return count;
        }
开发者ID:knifhen,项目名称:buttercup-swedish,代码行数:17,代码来源:DataContextTest.cs

示例7: PerformCleanup

        public static void PerformCleanup(IDirectory dir, string path, IFile file)
        {
            try
            {
                foreach(var v in dir.GetFiles(path).Where(a => a.Contains("tmp")))
                    file.Delete(v);
            }
            // ReSharper disable EmptyGeneralCatchClause
            catch
            // ReSharper restore EmptyGeneralCatchClause
            {
                //best effort.
            }

        }
开发者ID:Robin--,项目名称:Warewolf,代码行数:15,代码来源:ProgressFileDownloader.cs

示例8: createDirectoriesAndFiles

        private void createDirectoriesAndFiles(IDirectory sourceDirectory, IDirectory destinationDirectory, string name)
        {
            IDirectory destDir;

            if (name == null)
                destDir = destinationDirectory.CreateSubdirectory(sourceDirectory.Name);
            else
                destDir = destinationDirectory.CreateSubdirectory(name);

            foreach (var dir in sourceDirectory.GetDirectories())
            {
                createDirectoriesAndFiles(dir, destDir, null);
            }

            foreach (var file in sourceDirectory.GetFiles())
            {
                destDir.CreateFile(file);
            }
        }
开发者ID:emilw,项目名称:MPack,代码行数:19,代码来源:Engine.cs

示例9: findManifest

        private List<LocalTempList> findManifest(IDirectory rootDir)
        {
            var tempLocalList = new List<LocalTempList>();
            //"Manifest.xml"

            var file = rootDir.GetFiles(_manifestFileName).FirstOrDefault();

            if (file != null)
            {
                //Create the temp manifest file
                var localFileName = _localTempStorage.SaveManifest(file.GetBytes());
                tempLocalList.Add(new LocalTempList() { LocalPath = localFileName, PackageStorePath = file.FullName });
                Console.WriteLine("Found app at path: {0}", file.FullName);
            }
            else
            {
                foreach (var dir in rootDir.GetDirectories())
                {
                    tempLocalList.AddRange(findManifest(dir));
                }
            }

            return tempLocalList;
        }
开发者ID:emilw,项目名称:MPack,代码行数:24,代码来源:Engine.cs


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