An error was encountered writing the file to: "my file path". Error: System Events got an error: File some object wasn't open.
The test app code is shown below:
------------------------------------------
set thePodcast to ""
set xmlFile to "/Path/To/XMLFILE/file1.xml"
tell application "System Events"
set thePodcast to (contents of XML file xmlFile)
end tell
set posixPath to "/Path/To/XMLFILE/file2.xml"
set file_path to POSIX file posixPath
try
set open_file to open for access file_path with write permission
set eof of the open_file to 0
write thePodcast to open_file starting at eof
close access file file_path
on error error_message
try
close access file file_path
end try
display dialog "An error was encountered writing the file to: " & file_path & ". Error: " & error_message
end try
------------------------------------------
I have also tried
tell application "System Events"
write text of thePodcast to open_file starting at eof
end tell
close access file file_path
and it brings up the same error. I don't get the error if I just write text or suchlike to the open_file, so I suspect I am not doing something with XML suite that I should be doing! Anyone have any suggestions?
Cheers
Will