1 Reply Latest reply on Nov 4, 2009 3:29 PM by Chunick

    FileIO and Windows file updating

    czigany

      I am having a file problem with my Director application. I have two Director MX applications which run on different computers. They communicate with each other via a text file which is stored at a networked location. Both applications access the file and write to it. I have several users using the applications at the same time. Potentially, I could have 1 user using AppA and 8 users using AppB at one time.

       

      I am using the FileIO extra. When a user needs to update the file, the applications follow these steps:

           create the Fileio object

           open the file with write access

           read the file

           delete the file

           create the file

           open the file with write access

           write to the file

           close the file

           set the Fileio object to 0

       

      The problem occurs intermittently when users are accessing the file at approximately the same time. There are times when the correct information has apparently not been written to the file. For example, AppA reads the file, AppB reads the file, AppA writes new information to the file, AppB writes different new information to the file. Basically AppB's changes win and AppA's changes are lost.

       

      There also have been instances where the correct information has been written, but a user has accessed the information almost immediately and they receive the old information. If I check the file later, the correct information is there. I have seen similar behavior in the past where I've made changes to a text file but another application accessing that file still receives the old information. I believe this is a Windows issue where the file changes have not been actually stored yet.

       

      I really have two problems. First, there is apparently no way to lock the text file for the entire time it is being updated. I'm not sure this is solvable using Director and the FileIO xtra. Except for the moment between the delete and the open, I should have the file locked to other users. There is apparently no way, with the FileIO capability, of locking the file for the entire time.

       

      The second problem is the Windows issue with file changes taking some time to synch up. Is there a way to force the Windows text file to accept the changes so that I can be sure the next user is getting the absolutely latest file? I'm not sure how to describe the problem exactly to search for solutions. Is there a term for this?

       

      Any ideas are welcome. Thanks.