FILETOSTR(), as you would expect, returns an error (#1 File does not exist.) if the file to be read is not found.
On the other hand, STRTOFILE() does not error when it fails such as when trying to write a file to a folder that does not exist or to which the user does not have rights. It is the same result whether or not you send the third parameter to overwrite or append. Instead, it simply returns 0 as the number of bytes written. I suggest that whenever you use this function, test whether the returned value is less than the size of the string being written. If so, handle accordingly.
Okay, this is nothing new, but if you didn't realize the different behaviors between the two functions, you might have coded STRTOFILE() with the wrong assumption that this "failure" would be trapped by an error.
On the other hand, STRTOFILE() does not error when it fails such as when trying to write a file to a folder that does not exist or to which the user does not have rights. It is the same result whether or not you send the third parameter to overwrite or append. Instead, it simply returns 0 as the number of bytes written. I suggest that whenever you use this function, test whether the returned value is less than the size of the string being written. If so, handle accordingly.
Code:
myString = "This is a test."
IF STRTOFILE(myString,"C:\NoFolderExists\myFile.txt") <> LEN(myString)
MESSAGEBOX("String not written or partially written to file.")
ENDIF