⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 iteratefolders.cs

📁 Describe file property in vb
💻 CS
字号:
using System;
using io = System.Console;
using System.IO;

namespace Recursion
{
	class IterateFolders
	{

		public	static void Main(string[] args)
		{
			//Create a Directory object using DirectoryInfo 
			DirectoryInfo dir = new DirectoryInfo(@"C:\Program Files\Adobe\Acrobat 5.0");
			//Pass the Directory for displaying the contents
			getDirsFiles(dir);

		}


		public static void getDirsFiles(DirectoryInfo d)
		{
			//create an array of files using FileInfo object
			FileInfo [] files;
			//get all files for the current directory
			files = d.GetFiles("*.*");

			//iterte through the directory and print the files
			foreach (FileInfo file in files)
			{
				//get details of each file using file object
				String fileName = file.FullName;
				String fileSize = file.Length.ToString();
				String fileExtension =file.Extension;
				String fileCreated = file.LastWriteTime.ToString();

				io.WriteLine(fileName + " " + fileSize + " " + fileExtension + " " + fileCreated);
			}
			
			//get sub-folders for the current directory
			DirectoryInfo [] dirs = d.GetDirectories("*.*");
			
			//This is the code that calls the getDirsFiles
			//This is the stopping point for this recursion function.
			//It loops through until reaches the child folder.
			foreach (DirectoryInfo dir in dirs)
			{
				io.WriteLine("--------->> {0} ", dir.Name);
				getDirsFiles(dir);
			}
			
		}

		
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -