C # short code enumeration folder file (including subfolders)

xiaoxiao2021-03-06  38

Void getFileBydir (String DirPath, Ref ArrayList Al)

{

/ / List all files, add to Al

FOREACH (String File in Directory.GetFiles (DirPath))

Al.Add (file);

/ / List all the subfolders and call the getAllFileBydir themselves;

FOREACH (String Dir in Directory.GetDirectories (DirPath))

GetAllFileBydir (Dir, Ref Al);

}

After running this function, the Al is all files in the DirPath folder (including the subfolders);

转载请注明原文地址:https://www.9cbs.com/read-70051.html

New Post(0)