Use the winapi class to find files

Source: Internet
Author: User

How to Use winapi to find files from this article: http://spaces.msn.com/AxGeek/
In this example, many advanced axapta skills are used, such as function nesting.

The three functions used in this example are described as follows:

Fileexists (_ name) returns true if a file exists.
Folderexists (_ name) returns true if a folder or file exists.
Pathexists (_ name) returns true if a folder exists;

 

Static void findfile (ARGs _ ARGs)
{
# File
Filename fullfilename (filename _ path, filename _ filename)
{
Filename pathname;
Filename filename;
Filename fileextension;
;
[Pathname, filename, fileextension] = filenamesplit (_ filename );
Return _ path + '//' + filename + fileextension;
}

Void findfiles (filename _ path,
Filename _ filename,
Boolean _ inclsubdir = true,
Filename _ prefix = fullfilename (_ path, _ filename ))
{
Filename filename;
Int HDL;
;
Setprefix (_ prefix );
If (winapi: folderexists (_ path ))
{
[HDL, filename] = winapi: findfirstfile (fullfilename (_ path, _ filename ));
While (filename)
{
If (winapi: fileexists (fullfilename (_ path, filename )))
Info (filename );
Filename = winapi: findnextfile (HDL );
}
Winapi: findclose (HDL );
If (_ inclsubdir)
{
[HDL, filename] = winapi: findfirstfile (_ path + '//' + # allfiles );
While (filename)
{
If (strlwr (filename )! = Strlwr (_ filename )&&
Strlwr (filename )! = Strlwr ('.')&&
Strlwr (filename )! = Strlwr ('..')&&
Winapi: pathexists (fullfilename (_ path, filename )))
Findfiles (fullfilename (_ path, filename), _ filename, _ inclsubdir, filename );
Filename = winapi: findnextfile (HDL );
}
Winapi: findclose (HDL );
}
}
}
Findfiles ('C: // program files ',' *. Doc ');
}

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.