Article - CS289614

LoadText snippet in ThingWorx locks the file after loading it and cannot be read or modified afterwards

Modified: 08-Jul-2024   


Applies To

  • ThingWorx Platform 7.4 SP4 to 8.4 SP2

Description

  • LoadText snippet from ThingWorx is locking the file that was read and afterwards, the file cannot be modified
  • Run LoadText against any text file stored in any file repository, and then try to perform additional actions against the file, like a delete (either via the Composer or directly in file explorer on the machine); file will be locked and cannot be deleted
  • Unable to write to or delete a file from a repository after calling it in the LoadText service
  • Example of code that is loading content of a file in a variable, and then modify the file:
Things["SystemRepository"].SaveText({  path: 'test.txt',   content: 'text1'    });

var content = Things["SystemRepository"].LoadText({  path: 'test.txt'  });

Things["SystemRepository"].SaveText({ path: 'test.txt', content: 'text2' });
  • Running above code, error is occurring:
Wrapped java.io.FileNotFoundException: ..\ThingworxStorage\repository\Repository_thing\test.txt (The requested operation cannot be performed on a file with a user-mapped section open) Cause: ..\ThingworxStorage\repository\Repository_thing\test.txt (The requested operation cannot be performed on a file with a user-mapped section open)
This is a printer-friendly version of Article 289614 and may be out of date. For the latest version click CS289614