I used this code to delete all files that are contained in a directory: FilePath folder = "E:\\My uninstaller"; FilePath filePath; container fileInfo; int fileHandle; FileName fnameTmp;
; fnameTmp = folder; filePath = fnameTmp; if (substr(fnameTmp,strlen(fnameTmp)-1,1) == '\\') { fnameTmp = fnameTmp + '*.*'; } else { fnameTmp = fnameTmp + '\\*.*'; filePath = filePath + '\\'; } fileInfo = winAPI::findFirstFile(fnameTmp); fileHandle = conpeek(fileInfo,1); fnameTmp = winapi::findNextFile(fileHandle); while (fnametmp) { fnameTmp = winapi::findNextFile(fileHandle); if (fnameTmp != "") winAPI::deleteFile(filePath + fnameTmp); } In this manner, you can delete all the files... --- In Axapta-Knowledge-Village@yahoogroups.com, "Irving" <[EMAIL PROTECTED]> wrote: > > Hi > > I want to delete files in a folder, I have made following code: > > void deleteFilesInFolder(filePath _inputPath) > { > object cIo; > fileName inputFile; > filePath inputPath = _inputPath; > ; > > inputFile = this.SearchInputFile(inputPath); > cIo = new CommaIo(inputFile,'r'); > while(inputFile) > { > winAPI::DeleteFile(inputFile); > > //Get the next file... > inputFile = this.SearchInputFile(inputPath); > cIo = new CommaIo(inputFile,'r'); > } > } > > where SearInputFile has the following code: > FileName SearchInputFile(filePath _Path) > { > container fileInfo; > int findhandle; > filePath filePath; > FileName fileNameTmp; > ; > > fileNameTmp = _Path; > filePath = fileNameTmp; > > if (subStr(fileNameTmp,strlen(fileNameTmp)-1,1) == '\\') > { > fileNameTmp = fileNameTmp + '*.*'; > } > else > { > fileNameTmp = fileNameTmp + '\\*.*'; > filePath = filePath + '\\'; > } > > fileInfo = winAPI::FindFirstFile(fileNameTmp); > findHandle = conpeek(fileinfo,1); > fileNameTmp = winApi::FindNextFile(findHandle); > fileNameTmp = winApi::FindNextFile(findHandle); > winAPI::FindClose(findHandle); > > if (fileNameTmp) > return filePath + fileNameTmp; > > return ''; > } > > My problem is, that I find the first file again and again, each time > I try to delete it with winAPI::deleteFile(Filename). > > What is I doing wrong, I want to go throught the folders files and > delete them. > > Regards > > irving >