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 ');
}