Platforms to show: All Mac Windows Linux Cross-Platform

Back to NSFileManagerMBS class.

Previous items

NSFileManagerMBS.isReadableFile(path as folderitem) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method iCloud MBS MacCocoa Plugin 11.3 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns a Boolean value that indicates whether the invoking object appears able to read a specified file.
Example
dim m as new NSFileManagerMBS
dim f as FolderItem = SpecialFolder.Desktop.Child("notes.rtf")

MsgBox "Can read: "+str(m.isReadableFile(f))

path: A file path.

Returns true if the current process has read privileges for the file at path; otherwise false if the process does not have read privileges or the existence of the file could not be determined.

If the file at path is inaccessible to your application, perhaps because it does not have search privileges for one or more parent directories, this method returns false. This method traverses symbolic links in the path. This method also uses the real user ID and group ID, as opposed to the effective user and group IDs, to determine if the file is readable.

Note: Attempting to predicate behavior based on the current state of the file system or a particular file on the file system is not recommended. Doing so can cause odd behavior or race conditions. It's far better to attempt an operation (such as loading a file or creating a directory), check for errors, and handle those errors gracefully than it is to try to figure out ahead of time whether the operation will succeed. For more information on file system race conditions, see Race Conditions, File Operations, and Interprocess Communication in Secure Coding Guide.
http://developer.apple.com/library/mac/documentation/Security/Conceptual/SecureCodingGuide/Articles/RaceConditions.html#//apple_ref/doc/uid/TP40002585

NSFileManagerMBS.isUbiquitousItem(item as folderitem) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method iCloud MBS MacCocoa Plugin 11.3 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns a Boolean indicating whether the item is targeted for storage in iCloud.
Example
dim m as new NSFileManagerMBS
dim f as FolderItem = SpecialFolder.Desktop.Child("notes.rtf")

MsgBox "Is in iCloud: "+str(m.isUbiquitousItem(f))

item: Specify the folderitem for the file or directory whose status you want to check.

Returns true if the item is targeted for iCloud storage or false if it is not. This method also returns false if no item exists at url.

This method reflects only whether the item should be stored in iCloud because a call was made to the setUbiquitous method with a value of true for its flag parameter. This method does not reflect whether the file has actually been uploaded to any iCloud servers. To determine a file's upload status, check the IsUploadedMBS function in the folderitem class.

Available in Mac OS X v10.7 and later.

See also:

NSFileManagerMBS.isUbiquitousItem(URL as string) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method iCloud MBS MacCocoa Plugin 12.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns a Boolean indicating whether the item is targeted for storage in iCloud.

item: Specify the URL for the file or directory whose status you want to check.

Returns true if the item is targeted for iCloud storage or false if it is not. This method also returns false if no item exists at url.

This method reflects only whether the item should be stored in iCloud because a call was made to the setUbiquitous method with a value of true for its flag parameter. This method does not reflect whether the file has actually been uploaded to any iCloud servers. To determine a file's upload status, check the IsUploadedMBS function in the folderitem class.

Available in Mac OS X v10.7 and later.

See also:

NSFileManagerMBS.isWritableFile(path as folderitem) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method iCloud MBS MacCocoa Plugin 11.3 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns a Boolean value that indicates whether the invoking object appears able to write to a specified file.
Example
dim m as new NSFileManagerMBS
dim f as FolderItem = SpecialFolder.Desktop.Child("notes.rtf")

MsgBox "Can write: "+str(m.isWritableFile(f))

path: A file path.

Returns true if the current process has write privileges for the file at path; otherwise false if the process does not have write privileges or the existence of the file could not be determined.

If the file at path is inaccessible to your application, perhaps because it does not have search privileges for one or more parent directories, this method returns false. This method traverses symbolic links in the path. This method also uses the real user ID and group ID, as opposed to the effective user and group IDs, to determine if the file is writable.

Note: Attempting to predicate behavior based on the current state of the file system or a particular file on the file system is not recommended. Doing so can cause odd behavior or race conditions. It's far better to attempt an operation (such as loading a file or creating a directory), check for errors, and handle those errors gracefully than it is to try to figure out ahead of time whether the operation will succeed. For more information on file system race conditions, see Race Conditions, File Operations, and Interprocess Communication in Secure Coding Guide:
http://developer.apple.com/library/mac/documentation/Security/Conceptual/SecureCodingGuide/Articles/RaceConditions.html#//apple_ref/doc/uid/TP40002585

NSFileManagerMBS.linkItem(source as folderItem, dest as folderItem, byref error as NSErrorMBS) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method iCloud MBS MacCocoa Plugin 13.4 ✅ Yes ❌ No ❌ No ✅ Yes All
Creates a hard link between the items at the specified paths.

Source: The path that specifies the item you wish to link to. The value in this parameter must not be nil.
Dest: The path that identifies the location where the link will be created. The value in this parameter must not be nil.
error: If an error occurs, this pointer is set to an actual error object containing the error information.

Returns true if the hard link was created or NO if an error occurred. This method also returns false if a file, directory, or link already exists at dstPath.

Use this method to create hard links between files in the current file system. If Source is a directory, this method creates a new directory at Dest and then creates hard links for the items in that directory. If Source is (or contains) a symbolic link, the symbolic link is copied to the new location and not converted to a hard link.

Available in OS X v10.5 and later.

See also:

NSFileManagerMBS.linkItem(sourcePath as String, destPath as String, byref error as NSErrorMBS) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method iCloud MBS MacCocoa Plugin 19.5 ✅ Yes ❌ No ❌ No ✅ Yes All
Creates a hard link between the items at the specified paths.

Source: The path that specifies the item you wish to link to. The value in this parameter must not be nil.
Dest: The path that identifies the location where the link will be created. The value in this parameter must not be nil.
error: If an error occurs, this pointer is set to an actual error object containing the error information.

Returns true if the hard link was created or NO if an error occurred. This method also returns false if a file, directory, or link already exists at dstPath.

Use this method to create hard links between files in the current file system. If Source is a directory, this method creates a new directory at Dest and then creates hard links for the items in that directory. If Source is (or contains) a symbolic link, the symbolic link is copied to the new location and not converted to a hard link.

Available in OS X v10.5 and later.

See also:

NSFileManagerMBS.moveItem(source as folderItem, dest as folderItem, byref error as NSErrorMBS) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method iCloud MBS MacCocoa Plugin 13.4 ✅ Yes ❌ No ❌ No ✅ Yes All
Moves the file or directory at the specified path to a new location synchronously.

source: The path to the file or directory you want to move. This parameter must not be nil.
dest: The new path for the item in Source. This path must include the name of the file or directory in its new location. This parameter must not be nil.
error: If an error occurs, this is set to an actual error object containing the error information.

Returns true if the item was moved successfully or the file manager's delegate aborted the operation deliberately. Returns NO if an error occurred.

When moving items, the current process must have permission to read the item at Source and write the parent directory of Dest. If the item at Source is a directory, this method moves the directory and all of its contents, including any hidden files. If an item with the same name already exists at Dest, this method aborts the move attempt and returns an appropriate error. If the last component of Source is a symbolic link, only the link is moved to the new path; the item pointed to by the link remains at its current location.

If the source and destination of the move operation are not on the same volume, this method copies the item first and then removes it from its current location. This behavior may trigger additional delegate notifications related to copying and removing individual items.

Available in OS X v10.5 and later.

See also:

NSFileManagerMBS.moveItem(sourcePath as String, destPath as String, byref error as NSErrorMBS) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method iCloud MBS MacCocoa Plugin 19.5 ✅ Yes ❌ No ❌ No ✅ Yes All
Moves the file or directory at the specified path to a new location synchronously.

source: The path to the file or directory you want to move. This parameter must not be nil.
dest: The new path for the item in Source. This path must include the name of the file or directory in its new location. This parameter must not be nil.
error: If an error occurs, this is set to an actual error object containing the error information.

Returns true if the item was moved successfully or the file manager's delegate aborted the operation deliberately. Returns NO if an error occurred.

When moving items, the current process must have permission to read the item at Source and write the parent directory of Dest. If the item at Source is a directory, this method moves the directory and all of its contents, including any hidden files. If an item with the same name already exists at Dest, this method aborts the move attempt and returns an appropriate error. If the last component of Source is a symbolic link, only the link is moved to the new path; the item pointed to by the link remains at its current location.

If the source and destination of the move operation are not on the same volume, this method copies the item first and then removes it from its current location. This behavior may trigger additional delegate notifications related to copying and removing individual items.

Available in OS X v10.5 and later.

See also:

NSFileManagerMBS.removeItem(file as folderitem, byref error as NSErrorMBS) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method iCloud MBS MacCocoa Plugin 13.4 ✅ Yes ❌ No ❌ No ✅ Yes All
Removes the file or directory at the specified path.

path: A path string indicating the file or directory to remove. If the path specifies a directory, the contents of that directory are recursively removed.
error: If an error occurs, this is set to an actual error object containing the error information.

Returns true if the item was removed successfully or if path was nil. Returns false if an error occurred. If the delegate aborts the operation for a file, this method returns true. However, if the delegate aborts the operation for a directory, this method returns false.

Available in OS X v10.5 and later.

See also:

NSFileManagerMBS.removeItem(path as string, byref error as NSErrorMBS) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method iCloud MBS MacCocoa Plugin 13.4 ✅ Yes ❌ No ❌ No ✅ Yes All
Removes the file or directory at the specified path.

path: A path string indicating the file or directory to remove. If the path specifies a directory, the contents of that directory are recursively removed.
error: If an error occurs, this is set to an actual error object containing the error information.

Returns true if the item was removed successfully or if path was nil. Returns false if an error occurred. If the delegate aborts the operation for a file, this method returns true. However, if the delegate aborts the operation for a directory, this method returns false.

Available in OS X v10.5 and later.

See also:

NSFileManagerMBS.replaceItem(originalItem as FolderItem, newItem as FolderItem, backupItemName as String, options as integer, byref resultingItem as FolderItem, byref error as NSErrorMBS) as Boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method iCloud MBS MacCocoa Plugin 19.3 ✅ Yes ❌ No ❌ No ✅ Yes All
Replaces the contents of the item at the specified URL in a manner that ensures no data loss occurs.
Example
Dim fileManager As New NSFileManagerMBS

Dim source As FolderItem = SpecialFolder.Desktop.Child("test.rtf")
Dim dest As FolderItem = SpecialFolder.Desktop.Child("dest.rtf")

Dim result As Boolean
Dim output As FolderItem
Dim error As NSErrorMBS

result = fileManager.replaceItemAtURL(dest, source, "", 0, output, error)

If result Then
MsgBox output.NativePath
Else
MsgBox error.LocalizedDescription
End If

originalItem: The item containing the content you want to replace.
newItem: The item containing the new content for originalItem. It is recommended that you put this item in a temporary directory as provided by the OS. If a temporary directory is not available, put this item in a uniquely named directory that is in the same directory as the original item.
backupItemName: If provided, the name used to create a backup of the original item.
The backup is automatically placed in the same directory as the original item. If an error occurs during the creation of the backup item, the operation fails. If there is already an item with the same name as the backup item, that item will be removed.
The backup item will be removed in the event of success unless the NSFileManagerItemReplacementWithoutDeletingBackupItem option is provided in options.
options: The options to use during the replacement. Typically, you pass NSFileManagerItemReplacementUsingNewMetadataOnly for this parameter, which uses only the metadata from the new item. You can also combine the options described in NSFileManagerItemReplacementOptions using the C-bitwise OR operator.
resultingItem: On input, a variale for a folderitem variable. When the item is replaced, this variable is set to the folderitem of the new item. If no new file system object is required, the folderitem in this parameter may be the same passed to the originalItem parameter. However, if a new file system object is required, the folderitem may be different. For example, replacing an RTF document with an RTFD document requires the creation of a new file.
error: On input, a variable for an error object. If an error occurs, this variable is set to an error object containing the error information.

Returns true if the replacement was successful or false if an error occurred.

By default, the creation date, permissions, Finder label and color, and Spotlight comments of the original item are preserved on the new item. You can configure which metadata is preserved using the options parameter.
This method works only when the originalItem and newItem parameters are located on the same volume. Attempting to call this method by passing originalItem and newItem parameters that have locations on different volumes results in an error. Instead, you can call the URLForDirectory method, passing NSItemReplacementDirectory as the search path directory, to get a temporary URL on the destination's volume that is suitable for use with this method.
If an error occurs and the original item is not in the original location or a temporary location, the resulting error object contains a user info dictionary with the key "NSFileOriginalItemLocationKey". The value assigned to that key is an URL with the location of the item. The error code is one of the file-related errors described in NSError Codes.

Some examples using this method:

NSFileManagerMBS.replaceItemAtURL(originalItemURL as string, newItemURL as String, backupItemName as String, options as integer, byref resultingURL as String, byref error as NSErrorMBS) as Boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method iCloud MBS MacCocoa Plugin 19.3 ✅ Yes ❌ No ❌ No ✅ Yes All
Replaces the contents of the item at the specified URL in a manner that ensures no data loss occurs.

originalItemURL: The item containing the content you want to replace.
newItemURL: The item containing the new content for originalItemURL. It is recommended that you put this item in a temporary directory as provided by the OS. If a temporary directory is not available, put this item in a uniquely named directory that is in the same directory as the original item.
backupItemName: If provided, the name used to create a backup of the original item.
The backup is automatically placed in the same directory as the original item. If an error occurs during the creation of the backup item, the operation fails. If there is already an item with the same name as the backup item, that item will be removed.
The backup item will be removed in the event of success unless the NSFileManagerItemReplacementWithoutDeletingBackupItem option is provided in options.
options: The options to use during the replacement. Typically, you pass NSFileManagerItemReplacementUsingNewMetadataOnly for this parameter, which uses only the metadata from the new item. You can also combine the options described in NSFileManagerItemReplacementOptions using the C-bitwise OR operator.
resultingURL: On input, a variale for an URL variable. When the item is replaced, this variable is set to the URL of the new item. If no new file system object is required, the URL object in this parameter may be the same passed to the originalItemURL parameter. However, if a new file system object is required, the URL object may be different. For example, replacing an RTF document with an RTFD document requires the creation of a new file.
error: On input, a variable for an error object. If an error occurs, this variable is set to an error object containing the error information.

Returns true if the replacement was successful or false if an error occurred.

By default, the creation date, permissions, Finder label and color, and Spotlight comments of the original item are preserved on the new item. You can configure which metadata is preserved using the options parameter.
This method works only when the originalItemURL and newItemURL parameters are located on the same volume. Attempting to call this method by passing originalItemURL and newItemURL parameters that have locations on different volumes results in an error. Instead, you can call the URLForDirectory method, passing NSItemReplacementDirectory as the search path directory, to get a temporary URL on the destination's volume that is suitable for use with this method.
If an error occurs and the original item is not in the original location or a temporary location, the resulting error object contains a user info dictionary with the key "NSFileOriginalItemLocationKey". The value assigned to that key is an URL with the location of the item. The error code is one of the file-related errors described in NSError Codes.

NSFileManagerMBS.setAttributes(attributesDic as dictionary, item as folderitem, byref error as NSErrorMBS) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method iCloud MBS MacCocoa Plugin 12.3 ✅ Yes ❌ No ❌ No ✅ Yes All
Sets the attributes of the specified file or directory.

attributes: A dictionary containing as keys the attributes to set for path and as values the corresponding value for the attribute. You can set the following attributes: NSFileBusy, NSFileCreationDate, NSFileExtensionHidden, NSFileGroupOwnerAccountID, NSFileGroupOwnerAccountName, NSFileHFSCreatorCode, NSFileHFSTypeCode, NSFileImmutable, NSFileModificationDate, NSFileOwnerAccountID, NSFileOwnerAccountName, NSFilePosixPermissions. You can change single attributes or any combination of attributes; you need not specify keys for all attributes.
item: The folderitem of a file or directory.
error: If an error occurs, this is set to an actual error object containing the error information.

Returns true if all changes succeed. If any change fails, returns false, but it is undefined whether any changes actually occurred.

Discussion
As in the POSIX standard, the application either must own the file or directory or must be running as superuser for attribute changes to take effect. The method attempts to make all changes specified in attributes and ignores any rejection of an attempted modification. If the last component of the path is a symbolic link it is traversed.

The NSFilePosixPermissions value must be initialized with the code representing the POSIX file-permissions bit pattern. NSFileHFSCreatorCode and NSFileHFSTypeCode will only be heeded when path specifies a file.

Available in Mac OS X v10.5 and later.

See also:

NSFileManagerMBS.setAttributes(attributesDic as dictionary, path as string, byref error as NSErrorMBS) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method iCloud MBS MacCocoa Plugin 12.3 ✅ Yes ❌ No ❌ No ✅ Yes All
Sets the attributes of the specified file or directory.

attributes: A dictionary containing as keys the attributes to set for path and as values the corresponding value for the attribute. You can set the following attributes: NSFileBusy, NSFileCreationDate, NSFileExtensionHidden, NSFileGroupOwnerAccountID, NSFileGroupOwnerAccountName, NSFileHFSCreatorCode, NSFileHFSTypeCode, NSFileImmutable, NSFileModificationDate, NSFileOwnerAccountID, NSFileOwnerAccountName, NSFilePosixPermissions. You can change single attributes or any combination of attributes; you need not specify keys for all attributes.
path: The path of a file or directory.
error: If an error occurs, this is set to an actual error object containing the error information.

Returns true if all changes succeed. If any change fails, returns false, but it is undefined whether any changes actually occurred.

Discussion
As in the POSIX standard, the application either must own the file or directory or must be running as superuser for attribute changes to take effect. The method attempts to make all changes specified in attributes and ignores any rejection of an attempted modification. If the last component of the path is a symbolic link it is traversed.

The NSFilePosixPermissions value must be initialized with the code representing the POSIX file-permissions bit pattern. NSFileHFSCreatorCode and NSFileHFSTypeCode will only be heeded when path specifies a file.

Available in Mac OS X v10.5 and later.

See also:

NSFileManagerMBS.setUbiquitous(flag as boolean, item as folderitem, destitem as folderitem, byref error as NSErrorMBS) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method iCloud MBS MacCocoa Plugin 11.3 ✅ Yes ❌ No ❌ No ✅ Yes All
Sets whether the item at the specified URL should be stored in the cloud.

flag: Specify true to move the item to iCloud or false to remove it from iCloud (if it is there currently).
item: Specify the folderitem of the item (file or directory) that you want to store in iCloud.
destitem: Specify the location in iCloud at which to store the file or directory. This folderitem must be constructed from a folderitem returned by the URLForUbiquityContainerIdentifier method, which you use to retrieve the desired iCloud container directory. The folderitem you specify may contain additional subdirectories so that you can organize your files hierarchically in iCloud. However, you are responsible for creating those intermediate subdirectories (using the NSFileManagerMBS or folderitem class) in your iCloud container directory.
error: If an error occurs, this pointer is set to an NSError object containing information about the error. You may specify nil for this parameter if you do not want the error information.

Returns yes if the item's status was updated successfully or false if an error occurred. If this method returns false and you specified a value for the error parameter, this method returns an error object.

Use this method to move a file from its current location to iCloud. For files located in an application's sandbox, this involves physically removing the file from the sandbox directory. (The system extends your application's sandbox privileges to give it access to files it moves to iCloud.) You can also use this method to move files out of iCloud and back into a local directory.

Your application must have an active file presenter object configured to monitor the specified file or directory before calling this method. When you specify true for the flag parameter, this method attempts to move the file or directory to the cloud and returns true if it is successful. This method also notifies your file presenter of the new location of the file so that your application can continue to operate on it.

Important: Do not call this method from your application's main thread. This method performs a coordinated write operation on the file you specify, and calling this method from the main thread can trigger a deadlock with the file presenter you have monitoring the file. Instead, use a dispatch queue (other than the main thread queue) to perform the method call on a secondary thread. You can always message your main thread after the call finishes to update the rest of your application's data structures.

Available in Mac OS X v10.7 and later.

See also:

Some examples using this method:

NSFileManagerMBS.setUbiquitous(flag as boolean, item as folderitem, destURL as string, byref error as NSErrorMBS) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method iCloud MBS MacCocoa Plugin 12.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Sets whether the item at the specified URL should be stored in the cloud.

flag: Specify true to move the item to iCloud or false to remove it from iCloud (if it is there currently).
item: Specify the folderitem of the item (file or directory) that you want to store in iCloud.
destitem: Specify the location in iCloud at which to store the file or directory. This folderitem must be constructed from a folderitem returned by the URLForUbiquityContainerIdentifier method, which you use to retrieve the desired iCloud container directory. The folderitem you specify may contain additional subdirectories so that you can organize your files hierarchically in iCloud. However, you are responsible for creating those intermediate subdirectories (using the NSFileManagerMBS or folderitem class) in your iCloud container directory.
error: If an error occurs, this pointer is set to an NSError object containing information about the error. You may specify nil for this parameter if you do not want the error information.

Returns yes if the item's status was updated successfully or false if an error occurred. If this method returns false and you specified a value for the error parameter, this method returns an error object.

Use this method to move a file from its current location to iCloud. For files located in an application's sandbox, this involves physically removing the file from the sandbox directory. (The system extends your application's sandbox privileges to give it access to files it moves to iCloud.) You can also use this method to move files out of iCloud and back into a local directory.

Your application must have an active file presenter object configured to monitor the specified file or directory before calling this method. When you specify true for the flag parameter, this method attempts to move the file or directory to the cloud and returns true if it is successful. This method also notifies your file presenter of the new location of the file so that your application can continue to operate on it.

Important: Do not call this method from your application's main thread. This method performs a coordinated write operation on the file you specify, and calling this method from the main thread can trigger a deadlock with the file presenter you have monitoring the file. Instead, use a dispatch queue (other than the main thread queue) to perform the method call on a secondary thread. You can always message your main thread after the call finishes to update the rest of your application's data structures.

Available in Mac OS X v10.7 and later.

See also:

NSFileManagerMBS.startDownloadingUbiquitousItem(item as folderitem, byref error as NSErrorMBS) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method iCloud MBS MacCocoa Plugin 11.3 ✅ Yes ❌ No ❌ No ✅ Yes All
Starts downloading (if necessary) the specified item to the local system.

item: Specify the folderitem for the file or directory in the cloud that you want to download.
error: On input, a pointer to variable for an NSError object. If an error occurs, this pointer is set to an NSError object containing information about the error. Y

Returns true if the download started successfully or was not necessary, otherwise false. If false is returned and error is not nil, an NSError object describing the error is returned in that parameter.

If a cloud-based file or directory has not been downloaded yet, calling this method starts the download process. If the item exists locally, calling this method synchronizes the local copy with the version in the cloud.

For a given folderitem, you can determine if a file is downloaded by getting the value of the IsDownloaded method. You can also use related methods to determine the current progress in downloading the file.

Available in Mac OS X v10.7 and later.

See also:

NSFileManagerMBS.startDownloadingUbiquitousItem(URL as string, byref error as NSErrorMBS) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method iCloud MBS MacCocoa Plugin 12.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Starts downloading (if necessary) the specified item to the local system.

item: Specify the URL for the file or directory in the cloud that you want to download.
error: On input, a pointer to variable for an NSError object. If an error occurs, this pointer is set to an NSError object containing information about the error. Y

Returns true if the download started successfully or was not necessary, otherwise false. If false is returned and error is not nil, an NSError object describing the error is returned in that parameter.

If a cloud-based file or directory has not been downloaded yet, calling this method starts the download process. If the item exists locally, calling this method synchronizes the local copy with the version in the cloud.

For a given folderitem, you can determine if a file is downloaded by getting the value of the IsDownloaded method. You can also use related methods to determine the current progress in downloading the file.

Available in Mac OS X v10.7 and later.

See also:

NSFileManagerMBS.trashItem(file as folderItem, byref Resulting as folderItem, byref error as NSErrorMBS) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method iCloud MBS MacCocoa Plugin 13.4 ✅ Yes ❌ No ❌ No ✅ Yes All
Moves an item to the trash.

Returns true if the item at url was successfully moved to the trash. Since the operation may require renaming the item to avoid a file name collision, this method returns, by reference, the resulting folderitem that the item was moved to.

If this method returns false, the item was not moved to the trash; the error parameter then contains information about the error.

Available in OS X v10.8 and later.

See also:

NSFileManagerMBS.trashItem(Path as String, byref Resulting as FolderItem, byref error as NSErrorMBS) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method iCloud MBS MacCocoa Plugin 19.5 ✅ Yes ❌ No ❌ No ✅ Yes All
Moves an item to the trash.

Returns true if the item at url was successfully moved to the trash. Since the operation may require renaming the item to avoid a file name collision, this method returns, by reference, the resulting folderitem that the item was moved to.

If this method returns false, the item was not moved to the trash; the error parameter then contains information about the error.

Available in OS X v10.8 and later.

See also:

NSFileManagerMBS.URLForPublishingUbiquitousItem(item as folderitem, byref expirationDate as date, byref error as NSErrorMBS) as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method iCloud MBS MacCocoa Plugin 11.3 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Returns a URL that can be emailed to users to allow them to download a copy of a cloud-based item.
Example
dim m as new NSFileManagerMBS
dim f as FolderItem = SpecialFolder.Desktop.Child("test.rtf")

dim error as NSErrorMBS
dim exdate as date
dim url as string = m.URLForPublishingUbiquitousItem(f, exdate, error)

// always fails as desktop folder is not in cloud
if error<>nil then
MsgBox error.localizedDescription
end if

url: Specify the URL of the item in the cloud that you want to share. The URL must be prefixed with the base URL returned from the URLForUbiquityContainerIdentifier method that corresponds to the item's location.
expirationDate: On output, this parameter contains the date after which the item is no longer available at the returned URL.
error: If an error occurs, this pointer is set to an NSError object containing information about the error.

Returns an URL with which users can download a copy of the item at url. Returns nil if the URL could not be created for any reason.

Discussion
This method creates a snapshot of the specified file and places that copy in a temporary iCloud location where it can be accessed by other users using the returned URL. The snapshot reflects the contents of the file at the time the URL was generated and is not updated when subsequent changes are made to the original file in the user's iCloud storage. The snapshot file remains available at the specified URL until the date specified in the outDate parameter, after which it is automatically deleted.

Your application must have access to the network for this call to succeed.
Available in Mac OS X v10.7 and later.

See also:

Some examples using this method:

NSFileManagerMBS.URLForPublishingUbiquitousItem(URL as string, byref expirationDate as date, byref error as NSErrorMBS) as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method iCloud MBS MacCocoa Plugin 12.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Returns a URL that can be emailed to users to allow them to download a copy of a cloud-based item.

url: Specify the URL of the item in the cloud that you want to share. The URL must be prefixed with the base URL returned from the URLForUbiquityContainerIdentifier method that corresponds to the item's location.
expirationDate: On output, this parameter contains the date after which the item is no longer available at the returned URL.
error: If an error occurs, this pointer is set to an NSError object containing information about the error.

Returns an URL with which users can download a copy of the item at url. Returns nil if the URL could not be created for any reason.

Discussion
This method creates a snapshot of the specified file and places that copy in a temporary iCloud location where it can be accessed by other users using the returned URL. The snapshot reflects the contents of the file at the time the URL was generated and is not updated when subsequent changes are made to the original file in the user's iCloud storage. The snapshot file remains available at the specified URL until the date specified in the outDate parameter, after which it is automatically deleted.

Your application must have access to the network for this call to succeed.
Available in Mac OS X v10.7 and later.

See also:

NSFileManagerMBS.URLForUbiquityContainerIdentifier(containerIdentifier as string) as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method iCloud MBS MacCocoa Plugin 12.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns the iCloud directory associated with the specified container ID.

containerID: Specify the container ID of the cloud-based storage container. The string you specify must not contain wildcards and must be of the form <TEAMID>.<CONTAINER>, where <TEAMID> is your development team ID and <CONTAINER> describes the bundle identifier of the container you want to access. The container identifiers for your application must be declared in the com.apple.developer.ubiquity-container-identifiers entitlement.
If you specify "", this method returns the first container listed in the com.apple.developer.ubiquity-container-identifiers entitlement.

Returns a folderitem pointing to the specified container directory or nil if the container could not be located or if iCloud storage is unavailable for the current user or device.

You can use the folderitem returned by this method to build paths to files and directories in the user's iCloud storage. Each application that syncs documents to the cloud must have at least one associated container directory in which to put those files. This container directory can be unique to the application or shared by multiple applications. You use this method to retrieve the folderitem for that container directory.

In addition to writing to its own container directory, an application can write to any container directory for which it has the appropriate permission. Each additional container directory should be listed as an additional value in the com.apple.developer.ubiquity-container-identifiers entitlement.

Note: The development team ID that precedes each container ID string is the unique identifier associated with your development team. You can find this string in the Member Center of the Apple Developer website (http://developer.apple.com/membercenter). From the Member Center home page, select the Your Account tab and then select Organization Profile from the column on the left of that tab. Your team's identifier is in the Company/Organization ID field.
The first time you call this method for a given container directory, iOS extends your application sandbox to include that container directory. Thus, it is important that you call this method at least once before trying to search for files in iCloud. And if your application accesses multiple container directories, you should call the method once for each directory.

Available in Mac OS X v10.7 and later.
FileForUbiquityContainerIdentifier returns folderitem while URLForUbiquityContainerIdentifier returns URL string.

Some examples using this method:

Previous items

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


The biggest plugin in space...