static void Jimmy_FindFileType(Args _args) { #File #WinAPI Dialog dlg = new Dialog("Please selected Path and file Extension"); DialogField dlgFile = dlg.addField(typeid(filePath)); DialogField dlgType = dlg.addField(typeid(filenameType)); filePath filePath; int i; 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))) { i++; info(strfmt("File Name: %1,Path: %2, %3, %4",fileName,_path,i,Conpeek(fileNameSplit(_fileName),3))); } 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); } } } dlgFile.value(Winapi::getFolderPath(#CSIDL_PERSONAL)); dlgType.value("*.doc"); dlg.doInit(); if(!dlg.run()) return ; filePath = dlgFile.value(); findFiles(filePath,dlgType.value()); } /* Axapta’s WinAPI class has a bunch of static methods to handle files. The code example below shows how to utilize some of these methods to find files. The two methods used to fetch all files matching the search criteria are findFirstFile() and findNextFile(). Don’t forget to clean up after yourself with findClose(). The code also uses three different find methods: 1)fileExists(_name) returns true, if _name is an existing file 2)folderExists(_name) returns true, if _name is an existing file or folder 3)pathExists(_name) returns true, if _name is an existing folder The example uses the infolog for output. As with any infolog beware of performance and limitation to 10.000 lines. */
x++ Find Folder and File Type
原创
©著作权归作者所有:来自51CTO博客作者fandyx的原创作品,请联系作者获取转载授权,否则将追究法律责任
上一篇:helpless....
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
lua数组多重结构
1. 数组: 使用整数来索引table即可在Lua中实现数组。因此,Lua中的数组没有固定的大小,如: a = {} for i = 1, 1000 do a[i] = 0 end print("The length o
lua数组多重结构 lua 数据结构与算法 java Lua