c# 获取目录下文件的代码
本文导语: //取得工作目录下的文件 代码示例: public static ArrayList ListFiles(string strFolderEntry) { ArrayList objFileList = new ArrayList(); ListFilesFormFolder(strFolderEntry, ref objFileList); return objFileList; } private static void ListFilesFor...
//取得工作目录下的文件
public static ArrayList ListFiles(string strFolderEntry)
{
ArrayList objFileList = new ArrayList();
ListFilesFormFolder(strFolderEntry, ref objFileList);
return objFileList;
}
private static void ListFilesFormFolder(string strFolderEntry, ref ArrayList objFileList)
{
foreach (string strFile in Directory.GetFiles(strFolderEntry))
{
if (!objFileList.Contains(strFile))
{
objFileList.Add(strFile);
}
}
foreach (string strFolder in Directory.GetDirectories(strFolderEntry))
{
ListFilesFormFolder(strFolder, ref objFileList);
}
}