c#

位置:IT落伍者 >> c# >> 浏览文章

C#遍历文件夹返回列表类


发布日期:2018年04月19日
 
C#遍历文件夹返回列表类

using System;

using SystemCollectionsGeneric;

using SystemCollections;

using SystemText;

using SystemIO;

namespace JiangmingxiangProgramFileList

{

public class FileList

{

//字段声明

private ArrayList myfilelistpath = new ArrayList();

private ArrayList myfilelistname = new ArrayList();

//属性声明

public ArrayList GetFileListPath

{

get { return myfilelistpath; }

}

public ArrayList GetFileListName

{

get { return myfilelistname; }

}

//构造函数

public FileList(string sourceDirectory)

{

DirectoryInfo diSource = new DirectoryInfo(sourceDirectory);

ListAll(diSource);

}

public void ListAll(DirectoryInfo source)

{

foreach (FileInfo fi in sourceGetFiles())

{

myfilelistpathAdd(fiFullName + fiName);

myfilelistnameAdd(fiName);

}

foreach (DirectoryInfo diSourceSubDir in sourceGetDirectories())

{

ListAll(diSourceSubDir);

}

}

}

}

上一篇:I2C总线的模拟器的.Net Micro Framework实现

下一篇:教你如何有效监控.NET应用程序