//加上搜索后缀,得到类似'c:\*.*' 、'c:\windows\*.*'的搜索路径 tmpStr := path + '*.*'; //在当前目录查找第一个文件、子目录 found := FindFirst(tmpStr, faAnyFile, searchRec); while found = 0 do //找到了一个文件或目录后 begin fn := path + searchRec.Name;
if (searchRec.Name <> '.') and (searchRec.Name <> '..') then begin //如果找到的是个目录 if ((searchRec.Attr and faDirectory) <> 0) then begin
end else//如果是文件 begin //ListAdd(searchRec, fn);//fileList.Add(fn); _count := _count + 1; end; end;
The directory or path, and the file name. The file name can include wildcard characters, for example, an asterisk (*) or a question mark (?).
This parameter should not be NULL, an invalid string (for example, an empty string or a string that is missing the terminating null character), or end in a trailing backslash ().
If the string ends with a wildcard, period, or directory name, the user must have access to the root and all subdirectories on the path.
In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to approximately 32,000 wide characters, call the Unicode version of the function (FindFirstFileExW), and prepend "\\?\" to the path. For more information, see Naming a File. Tip Starting in Windows 10, version 1607, for the unicode version of this function (FindFirstFileExW), you can opt-in to remove the MAX_PATH character limitation without prepending "\\?\". See the "Maximum Path Limitation" section of Naming Files, Paths, and Namespaces for details.