[Bug-11645] Message Handler Write File

So I’m using a message handler to write a file on the gateway server. Since upgrading to 8.0 I get a logged error saying “unable to create file”, but the file is created just empty. If I run the script again I don’t get the error, and the file is overwritten with information. It will only work if the file already exists, the first time around it creates an empty file and throws an error, second time it works without complaint.

Can you post the specific syntax you are using where the file was automatically being created in 7.9? I am not seeing the behavior you are describing as working in 7.9 and in the documentation for the system.file.writeFile function, it states that the file is written to if it exists. I just want to confirm that we are talking about the same function.


fileName = payload['fileName']
fileDir = ''
fileDir = 'D:\Templates\ ' + fileName

fileText = payload["xml"]
if fileText != '':
	system.file.writeFile(fileDir, fileText, 0)

First pass it fails, creates an empty file, second pass it populates the file with data.

This looks like a bug with the logic around creating “implicit” directories with writeFile. The change in behavior is due to the optional encoding arguments added to the system.file functions in 8.0. I’ve opened a ticket for it.

1 Like

Try changing to forward slashes and removing the extra space in fileDir.

Same behavior when I remove spaces and go with forward slashes.

When will the fix be released?

It should end up in a nightly build next week sometime.

1 Like

This issue was fixed in the build that was uploaded on 11/17. Please let us know if you continue to see this behavior after upgrading.

It has worked for me since that update.