Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

File Access Problem

  • yue-qi-qi

    yue-qi-qi - 2013-10-24

    I meet a problem when I use the File Access library to operate file access.
    after fbFileOpen() executed,the content of the file that the function block open will be cleard! And the size of the file will be 0!

  • yue-qi-qi

    yue-qi-qi - 2013-10-25

    I have just download the CoDeSys Examples of “FileUtilities”,that writes as:

    IF xInit THEN
    CASE iState OF
    0: //Open the specified file with write access.
    FileOpen(xExecute:= TRUE, sFileName:= sFileName, xExclusive:= FALSE, eFileMode:= File.MODE.MWRITE );
    IF FileOpen.xDone = TRUE THEN
    iState := 1;
    hfile := FileOpen.hFile;
    FileOpen(xExecute:= FALSE);
    ELSIF FileOpen.xError = TRUE THEN
    iState:= 32767;
    FileOpen(xExecute:= FALSE);

    The code above is tested on CoDeSys Control Win V3, and if there has exist a file which the sFileName specifies, and the file size is not 0, but after the above FileOpen() function executed and success with xFone=TRUE.the file size is 0, which means the file which is open with File.MODE.MWRITE mode will be cleared to empty!
    In my mind, if you open the file with File.MODE.MWRITE, if the file does not exists, the file will be created and opened;and if the file has existed, then the file will be opened and should be cleared to empty!
    But the test above shows that open a file with File.MODE.MWRITE mode means create a new file or clear an existing file to empty!

  • timvh

    timvh - 2013-10-29

    As I understand it correctly, what you say is in both cases the same.


Log in to post a comment.