Platforms to show: All Mac Windows Linux Cross-Platform
Back to NSWorkspaceMBS class.
NSWorkspaceMBS.openFile(file as folderitem) as boolean
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| shared method | Cocoa | MBS MacCocoa Plugin | 8.1 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
Returns true if the file was successfully opened; otherwise, false.
The sending application is deactivated before the request is sent.
See also:
- openFile(File as FolderItem, Application as FolderItem, configuration as NSWorkspaceOpenConfigurationMBS, tag as variant = nil)
- openFile(file as folderitem, appname as string) as boolean
- openFile(file as folderitem, appname as string, Deactivate as boolean) as boolean
- openFile(File as FolderItem, configuration as NSWorkspaceOpenConfigurationMBS, tag as variant = nil)
NSWorkspaceMBS.openFile(file as folderitem, appname as string) as boolean
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| shared method | Cocoa | MBS MacCocoa Plugin | 8.1 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
Returns true if the file was successfully opened; otherwise, false.
The appName parameter need not be specified with a full path and, in the case of an application wrapper, may be specified with or without the .app extension, as described in "Use of .app Extension". The sending application is deactivated before the request is sent.
See also:
- openFile(file as folderitem) as boolean
- openFile(File as FolderItem, Application as FolderItem, configuration as NSWorkspaceOpenConfigurationMBS, tag as variant = nil)
- openFile(file as folderitem, appname as string, Deactivate as boolean) as boolean
- openFile(File as FolderItem, configuration as NSWorkspaceOpenConfigurationMBS, tag as variant = nil)
NSWorkspaceMBS.openFile(file as folderitem, appname as string, Deactivate as boolean) as boolean
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| shared method | Cocoa | MBS MacCocoa Plugin | 8.1 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
appName: The name of the application to use when opening the file.
flag: If true, the sending application is deactivated before the request is sent, allowing the opening application to become the active application.
Returns true if the file was successfully opened; otherwise, false.
The appName parameter need not be specified with a full path and, in the case of an application wrapper, may be specified with or without the .app extension, as described in "Use of .app Extension". If appName is nil, the default application for the file's type is used.
See also:
- openFile(file as folderitem) as boolean
- openFile(File as FolderItem, Application as FolderItem, configuration as NSWorkspaceOpenConfigurationMBS, tag as variant = nil)
- openFile(file as folderitem, appname as string) as boolean
- openFile(File as FolderItem, configuration as NSWorkspaceOpenConfigurationMBS, tag as variant = nil)
NSWorkspaceMBS.openURL(url as string) as boolean
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| shared method | Cocoa | MBS MacCocoa Plugin | 8.1 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
Returns true if the location was successfully opened; otherwise, false.
See also:
- openURL(URL as String, ApplicationURL as String, configuration as NSWorkspaceOpenConfigurationMBS, tag as variant = nil)
- openURL(url as string, bundleIdentifier as string, options as Integer = &h00030000, AppleEventDescriptor as Variant = nil) as Boolean
- openURL(URL as String, configuration as NSWorkspaceOpenConfigurationMBS, tag as variant = nil)
Some examples using this method:
NSWorkspaceMBS.openURL(url as string, bundleIdentifier as string, options as Integer = &h00030000, AppleEventDescriptor as Variant = nil) as Boolean
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| shared method | Cocoa | MBS MacCocoa Plugin | 12.5 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
url: A URL for the application to open.
bundleIdentifier: A bundle identifier string or "" to use the default system bindings. This value corresponds to the value in the CFBundleIdentifier key of the application's Info.plist file. For example, the bundle identifier of the TextEdit application is com.apple.TextEdit.
options: Options to use when launching the application. Values for this parameter are described in constants.
descriptor: Additional options specified in an AppleEvent-style descriptor. For example, you could use this parameter to specify additional documents to open when the application is launched.
Returns true if the application was found and launched; otherwise, false.
See also:
NSWorkspaceMBS.performFileOperation(operation as string, source as folderitem, destination as folderitem, files() as string, byref tag as Integer) as boolean
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| shared method | Cocoa | MBS MacCocoa Plugin | 9.2 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
operation: The file operation to perform. The possible values for this parameter are described in "Constants."
source: The full path to the directory containing the files on which to operate.
destination: The full path to the destination directory of the operation.
files: An array of folderitems specifying the names of the files and directories to be manipulated. Each string must not contain any path information other than the name of the file or directory. In other words, all of the files and directories must be located in the source directory and not in one if its subdirectories.
tag: On input, a integer variable; on return, this variable contains a negative integer if the operation fails, 0 if he operation was performed synchronously and succeeded, or a positive integer if the operation was performed asynchronously. If the value is a positive integer, the value is a tag that identifies the requested file operation.
Return Value: True if the operation succeeded; otherwise, false.
Discussion:
Some operations—such as moving, copying, and linking files—require a destination directory to be specified. If not, destination should be the empty string (""). Before this method returns, it posts an NSWorkspaceDidPerformFileOperationNotification to the NSWorkspace object's notification center.
NSWorkspaceMBS.preferredFilenameExtensionForType(typeName as string) as string
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| shared method | Cocoa | MBS MacCocoa Plugin | 9.6 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
The appropriate filename extension for typeName, or "" if no extension could be determined.
NSWorkspaceMBS.selectFile(file as folderitem) as boolean
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| shared method | Cocoa | MBS MacCocoa Plugin | 8.1 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
Returns true on success.
For Windows, please use WinOpenFolderAndSelectItemsMBS function.
Some examples using this method:
NSWorkspaceMBS.setDesktopImageURL(file as folderitem, screen as NSScreenMBS, options as dictionary, byref error as NSErrorMBS) as boolean
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| shared method | Cocoa | MBS MacCocoa Plugin | 11.3 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop only |
file: The image file. The file must not be nil.
screen: The screen to set the desktop image on.
options: The options dictionary may contain any of the Desktop Image Dictionary Keys (NSWorkspaceDesktopImageScalingKey, NSWorkspaceDesktopImageAllowClippingKey or NSWorkspaceDesktopImageFillColorKey), which control how the image is scaled on the screen.
error: A error that is returned by-reference if setting the image fails.
Returns true if the image was set as the desktop, otherwise false. If false is returned, the error parameter provides additional information.
You should not present a user interface for picking the options. Instead, choose appropriate defaults and allow the user to adjust them in the System Preference Pane.
Available in Mac OS X v10.6 and later.
NSWorkspaceMBS.setIcon(image as NSImageMBS, file as folderitem, flags as Integer = 0) as boolean
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| shared method | Cocoa | MBS MacCocoa Plugin | 8.1 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
image: The image to use as the icon for the file or directory.
file: The full path of the file or directory.
flags: The icon representations to generate from the image. You specify this value by combining the appropriate NSWorkspaceIconCreationOptions constants, listed in Constants, using the C bitwise OR operator. Specify 0 if you want to generate icons in all available icon representation formats.
Returns true if the icon was set; otherwise, false.
The image can be an arbitrary image, with or without transparency. This image is automatically scaled (as needed) to generate the icon representations. The file or folder must exist and be writable by the user.
It is recommended that applications include the NSExclude10_4ElementsIconCreationOption option for compatibility with pre-Mac OS X v10.3 Finder. Icons that include the high resolution elements prevent custom icons from being displayed on earlier systems.
Before setting icon, make sure you close all Binarystream, Textoutputstream or other classes which may have the file open.
See also:
NSWorkspaceMBS.setIcon(image as NSImageMBS, path as string, flags as Integer = 0) as boolean
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| shared method | Cocoa | MBS MacCocoa Plugin | 8.1 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
image: The image to use as the icon for the file or directory.
path: The full path of the file or directory.
flags: The icon representations to generate from the image. You specify this value by combining the appropriate NSWorkspaceIconCreationOptions constants, listed in Constants, using the C bitwise OR operator. Specify 0 if you want to generate icons in all available icon representation formats.
Returns true if the icon was set; otherwise, false.
The image can be an arbitrary image, with or without transparency. This image is automatically scaled (as needed) to generate the icon representations. The file or folder must exist and be writable by the user.
It is recommended that applications include the NSExclude10_4ElementsIconCreationOption option for compatibility with pre-Mac OS X v10.3 Finder. Icons that include the high resolution elements prevent custom icons from being displayed on earlier systems.
Before setting icon, make sure you close all Binarystream, Textoutputstream or other classes which may have the file open.
See also:
NSWorkspaceMBS.showSearchResultsForQueryString(queryString as string) as boolean
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| shared method | Cocoa | MBS MacCocoa Plugin | 9.6 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
Returns true if the communication with Finder was successful, otherwise false.
Finder becomes the active application, if possible. The user can further refine the search via the Finder user interface.
Available in Mac OS X v10.6 and later.
NSWorkspaceMBS.typeOfFile(File as folderitem, byref error as NSErrorMBS) as string
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| shared method | Cocoa | MBS MacCocoa Plugin | 12.5 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
file: The absolute path of the file.
Error: If the Uniform Type Identifier of the file at absolutePath can't be determined, outError contains an NSError object that describes why.
Returns a string containing the uniform type identifier of the file at absoluteFilePath. If no UTI can be determined the return value is "".
If the file at the specified path is a symbolic link, the type of the symbolic link is returned.
See also:
NSWorkspaceMBS.typeOfFile(Path as string, byref error as NSErrorMBS) as string
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| shared method | Cocoa | MBS MacCocoa Plugin | 12.5 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
file: The absolute path of the file.
Error: If the Uniform Type Identifier of the file at absolutePath can't be determined, outError contains an NSError object that describes why.
Returns a string containing the uniform type identifier of the file at absoluteFilePath. If no UTI can be determined the return value is "".
If the file at the specified path is a symbolic link, the type of the symbolic link is returned.
See also:
NSWorkspaceMBS.unmountAndEjectDevice(item as folderitem, byref e as NSErrorMBS) as boolean
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| shared method | Cocoa | MBS MacCocoa Plugin | 11.3 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
Returns true if the volume was unmounted and ejected successfully, otherwise false, for example, if the volume is not ejectable.
error: If the operation fails, this error contains more information about the failure.
NSWorkspaceMBS.URLForApplicationToOpenURL(url as string) as string
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| shared method | Cocoa | MBS MacCocoa Plugin | 12.5 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
url: The URL of the file to open.
Returns the URL of the default application that would open the specified url. Returns "" if no application is able to open the url, or if the file url does not exist.
This is the programmatic equivalent of double clicking a document in the Finder.
NSWorkspaceMBS.URLForApplicationWithBundleIdentifier(bundleIdentifier as string) as string
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| shared method | Cocoa | MBS MacCocoa Plugin | 12.5 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
bundleIdentifier: A bundle identifier specifying an application.
Returns the URL of the application, or "" if no application has the bundle identifier.
This uses various (currently unspecified) heuristics in case multiple apps have the same bundle ID.
The items on this page are in the following plugins: MBS MacCocoa Plugin.