Xojo Developer Conference
25/27th April 2018 in Denver.
MBS Xojo Conference
6/7th September 2018 in Munich, Germany.

Platforms to show: All Mac Windows Linux Cross-Platform

ExchangeFilesMBS(first as folderitem, second as folderitem) as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
global method Files MBS Util Plugin 10.4 Yes Yes No Yes No
Function: Exchanges two files.
dim f1 as FolderItem = SpecialFolder.Desktop.Child("some picture.jpg")
dim f2 as FolderItem = SpecialFolder.Desktop.Child("another picture.jpg")

dim e as Integer = ExchangeFilesMBS(f1,f2)

MsgBox str(e) // show error code (0=no error)
On Mac swaps the contents of two files:

The ExchangeFilesMBS function allows programs to implement a "safe save" operation by creating and writing a complete new file and swapping the contents. An folderitem, alias, FSSpec, or FSRef that refers to the old file will now access the new data. The corresponding information in in-memory data structures are also exchanged.

Either or both files may have open access paths. After the exchange, the access path will refer to the opposite file's data (that is, to the same data it originally referred, which is now part of the other file).

On Windows files are renamed so they exchange their paths.

PS: Real Studio does not notice the change, so the folderitems you pass should no longer be used. To access the file, please make new folderitem with parent.truechild(filename).

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS Util Plugin.

MBS FileMaker Plugins