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


C# IDirectory.GetDirectories方法代码示例

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


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

示例3: 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

示例4: 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

示例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: BuildStructureFromFilePath

        private IList<IExplorerItem> BuildStructureFromFilePath(IDirectory directory, string path, string rootPath)
        {

            var firstGen =
                directory.GetDirectories(path)
                         .Where(a => !a.EndsWith("VersionControl"));

            IList<IExplorerItem> children = new List<IExplorerItem>();
            foreach(var resource in firstGen)
            {
                var resourcePath = resource.Replace(rootPath, "").Substring(1);

                var node = new ServerExplorerItem(new DirectoryInfo(resource).Name, Guid.NewGuid(), ResourceType.Folder, null, _authService.GetResourcePermissions(Guid.Empty), resourcePath);
                children.Add(node);
                node.Children = BuildStructureFromFilePath(directory, resource, rootPath);
            }
            return children;
        }
开发者ID:Robin--,项目名称:Warewolf,代码行数:18,代码来源:ExplorerItemFactory.cs

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