Xojo Cloud File Copy Fails

Using Xojo 2019R1 or 2019R2.1 and deploying to Xojo Cloud, the FolderItem.CopyFileTo command fails.

This code creates a Source and Output folder and creates Test.txt file in the Source folder.

dim f as FolderItem
dim aStream as BinaryStream

f = SpecialFolder.Documents.Child(“Source”)
f.CreateAsFolder
f = nil

f = SpecialFolder.Documents.Child(“Output”)
f.CreateAsFolder
#If TargetXojoCloud Then
dim sh as Shell
sh = New Shell
sh.Execute("chmod 777 " + f.ShellPath)
#EndIf
f = nil

f = SpecialFolder.Documents.Child(“Source”)
f = f.Child(“Test.txt”)
aStream = BinaryStream.Create(f,TRUE)
if aStream <> NIL then
aStream.Write(“Stuff”)
aStream.Close
end if
f = nil

This code attempts to copy Test.txt to the Output folder, but fails with Status: 2

dim FromFolderItem, ToFolderItem as FolderItem
FromFolderItem = SpecialFolder.Documents.Child(“Source”).Child(“Test.txt”)
ToFolderItem = SpecialFolder.Documents.Child(“Output”).Child(“Test.txt”)
FromFolderItem.CopyFileTo(ToFolderItem)
MsgBox("Status: " + Str(FromFolderItem.LastErrorCode))

If you Deploy the same App again, now the copy succeeds with Status: 0

If you run a similar test in the debugger, the test is successful the first time.

I saw a similar conversation posted on this forum 2 years ago, but no solution was given. It appears that Xojo Cloud allows a folder to be created, but does not allow files to be copied to that folder until you redeploy the App.

Any ideas?