API2: FolderItem.LastErrorCode

Regarding Xojo 2019 R2 FolderItem.LastErrorCode is no longer available (despite the Lang.Reference still speaks of // Check f.LastErrorCode

In the exaples in the LR is f.e. written:

f.MoveFileTo(g) MessageBox("success!")

How can i be sure the file has really been moved? Do i need to check if the file exists at the new position? Would be…not so good… :confused:

FolderItem is a bit an odd duck in API 2.
And honestly: I don’t quite see how things are supposed to be “correctly”.

See also feedback://showreport?report_id=57947.

API 1 Methods (that have not been deprecated and renamed to use API 2 -> Exceptions) should continue to set .LastErrorCode.
It’s still there, just doesn’t AutoComplete any more.

API 1:

  • FolderItem.CopyFileTo
  • FolderItem.MoveFileTo

API 2 (according to Documentation):

  • FolderItem.CreateAsFolder -> no Info, should continue using ErrorCodes
  • FolderItem.Delete (continues with ErrorCode)-> replaced by API 2: FolderItem.Remove (Exception)
  • FolderItem.CopyFileTo -> ErrorCodes
  • FolderItem.MoveFileTo -> Exception (according to documentation, not tested)

Hmm… Existing functionality in API 1 should NOT be changed.
FolderItem.MoveFileTo should continue setting ErrorCode…?

But what is it actually doing…? To me this seems to be quite a mess right now with FolderItem.
I hope this gets looked at and sorted in 2019r2.1.

Check both for Exceptions and .LastErrorCode?

To be really sure…:

(if it hasn’t existed there before; if your to-be-moved-file is no longer in its old location; …)

Should be exception based to anything that used .LastErrorCode:

Try f.MoveFileTo(g) MessageBox("success!") Catch err As IOException MessageBox("Not moved") End Try

Docs are full of flaws now

I’d like to mark both posts of @Jürg Otter and @Rick Araujo as Answer, but now marked Rick’s because in the future this will/should be the correct answer. :wink:

Thank you, to both of you.

The Docs have been updated:
FolderItem.MoveFileTo and FolderItem.CopyFileTo both continue to use .LastErrorCode.

The intent is that existing methods (API 1) keep working with error codes while new ones (API 2) throw exceptions.

It’s just that there currently aren’t new API 2 methods for FolderItem’s Move/Copy.
And it’s a bit unfortunate that .LastErrorCode doesn’t AutoComplete for FolderItem, even if it’s still being used by some of FolderItem’s Methods.
One could/should file a Feedback about that.

Well… Such property does not exist here: http://documentation.xojo.com/api/files/folderitem.html

And here: http://documentation.xojo.com/api/files/folderitem.html.LastErrorCode

They say “Don’t use it. Now the system uses exceptions”.

I think Xojo should come here, clarify the mess, and fix the manual.

1 Like