My programm looking for a file name 'retain' in a folder. To do it I'm using SysDirOpen to open folder directory then I'm using SysDirRead to listing files.
But at everytime, SysDirRead miss the first file in the directory. I don't know why.
Have you any idea ?
Below the part of my code :
VAR_GLOBALstDirHandle:SysDir.RTS_IEC_HANDLE;(*Folderpathresult*)stResultRead:SysDir.RTS_IEC_RESULT;(*StockRuntimeerrorcodeofSysDirRead*)stmaxNumbrebyteDir:DINT:=200;(*Maxbytenumberforafilenameinafilefolder*)pDirResult:POINTERTOSysDir.RTS_IEC_RESULT;(*OpenningFolderresult*)DirReadResult:STRING;(*StockSysDirReadresult*)config_list:ARRAY[0..19]OFSTRING(30);(*Arrayfillingbystandardretainconfig*)END_VAR(*Openingconfigdirectory*)stDirHandle:=sysDirOpen(szDir:=retainConfigFile.PathFolderFile,'',0,0,pResult:=pDirResult);(*Openchecking*)IFpDirResult=CmpErrors.Errors.ERR_OKTHEN(*Lookingforretainfileinconfigfolderandsavingtheminconfig_listwhilethereisfile's to read *) WHILE sysDirRead(hDir := stDirHandle, szDirEntry := DirReadResult, diMaxDirEntry := stmaxNumbrebyteDir, 0) <> CmpErrors.Errors.ERR_END_OF_OBJECT DO IF FIND(DirReadResult,'retain')=1THENconfig_list[_i]:=DirReadResult;END_IFEND_WHILEEND_IF
For example, in my folder I have these files : retaina_CHIP_T rev02.txt
retaina_CHIP_A rev01.txt
And szDirEntry will return in 3 loops : '.'
'retainaCHIPA rev01.txt'
'..'
thanks in advance for your help
Pierrick
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello everyone,
My programm looking for a file name 'retain' in a folder. To do it I'm using SysDirOpen to open folder directory then I'm using SysDirRead to listing files.
But at everytime, SysDirRead miss the first file in the directory. I don't know why.
Have you any idea ?
Below the part of my code :
For example, in my folder I have these files :
retaina_CHIP_T rev02.txt
retaina_CHIP_A rev01.txt
And szDirEntry will return in 3 loops :
'.'
'retainaCHIPA rev01.txt'
'..'
thanks in advance for your help
Pierrick
more posts ...
I have the same problem and no way to let it work.
Did you find a solution?
Thansk,
Dagi89
Hello dagi89,
The unique solution I have found to continue my project is to add a fake file which is not read by SysDirRead.
Hello, I also had this problem. I was able to solve it with the CAA File library. Here the example page:
https://content.helpme-codesys.com/en/libs/CAA%20File/Current/Examples.html