using System;
using System.Collections.Generic;
using System.IO;
namespace FileMan
{
class Program
{
static void Main(string[] args)
{
/// 文件系统
//Student s1 = new Student();
//s1.Name = "xiaohui";
//s1.Age = 12;
//Console.WriteLine(s1 is Student);
try
{
/// 列出所有的文件夹
string dirPath = "C:\\Users\\adley\\Desktop\\vite\\app01\\vite-project";
IEnumerable<string> listOfDirectories = Directory.EnumerateDirectories(dirPath);
foreach (var dir in listOfDirectories)
{
Console.WriteLine(dir);
}
Console.WriteLine("-------------------------------------");
/// 列出所有的文件
string filePath = "C:\\Users\\adley\\Desktop\\vite\\app01\\vite-project\\src";
IEnumerable<string> files = Directory.EnumerateFiles(filePath);
foreach(var file in files)
{
Console.WriteLine(file);
}
Console.WriteLine("-------------------------------------");
/// 匹配 递归去匹配所有的文件
IEnumerable<string> files2 = Directory.EnumerateFiles(filePath, "*.vue", SearchOption.AllDirectories);
foreach (var file in files2)
{
Console.WriteLine(file);
}
Console.WriteLine("-------------------------------------");
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
}
class Student
{
public string Name { get; set; }
public int Age { get; set; }
}
}