Obtains the list of specified types of files in the specified folder and Its subfiles.

Source: Internet
Author: User

// Retrieve the list of specified type files in the specified file category and its sub-Files

Procedure _ getfilelist (astrings: tstrings; asourfile, filename: string );
// Usage example: _ getfilelist (filelist, 'c: // ',' *. pa ')
VaR
Sour_path, sour_file: string;
Tmplist: tstringlist;
Filerec, subfilerec: tsearchrec;
I: integer;
Begin
If rightstr (TRIM (asourfile), 1) <> '/' then
Sour_path: = trim (asourfile) + '/'
Else
Sour_path: = trim (asourfile );
Sour_file: = filename;

If not directoryexists (sour_path) then
Begin
Astrings. Clear;
Exit;
End;

Tmplist: = tstringlist. Create;
Tmplist. Clear;

If findfirst (sour_path + filename, faanyfile, filerec) = 0 then
Repeat
If (filerec. ATTR and fadirectory) = 0) then
Astrings. Add (sour_path + filerec. Name );
Until findnext (filerec) <> 0;
If findfirst (sour_path + '*. *', faanyfile, filerec) = 0 then
Repeat
If (filerec. ATTR and fadirectory) <> 0) then
Begin
If (filerec. Name <> '.') and (filerec. Name <> '..') then
_ Getfilelist (astrings, sour_path + filerec. Name + '/', sour_file );
End;
Until findnext (filerec) <> 0;
Findclose (filerec );
End;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.