Delete JSON file after parsing
All,
I'm attempting to make a service on a FileRepository Thing that loads a JSON file, parses it and then deletes the file when finished. I am unable to get DeleteFile to work after using the loadJSON service. Thingworx seems to hold the file open for quite a while before releasing it. I've tried setting the variable I load the JSON into to a blank string and I've tried deleting the variable. I've also tried restarting the thing using me.RestartThing(). I've also tried creating a completely separate service to delete the file. This did not work either. The only way the file seems to get released is with time. Is there anyway to force Thingworx to let go of the file so it can be deleted? The code I am using in the service that only deletes the files is:
/* Get list of all files in the repository folder*/
var params = {
path: "" /* Default path. Change if storing in a different location */,
nameMask: undefined /* STRING */
};
var jsonFileList = me.GetFileListing(params);
for (var jsonCount = 0; jsonCount < jsonFileList.length;jsonCount++)
{
if (jsonFileList[jsonCount].name.indexOf("error") == -1)
{
var fileParams = {
path: jsonFileList[jsonCount].name /* STRING */
};
me.DeleteFile(fileParams);
var result = jsonFileList[jsonCount].name;
}
}
This works fine as long as another service has not loaded the file using loadJSON. Any help would be appreciated. I'm using Thingworx 7.4.0-b159

