You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
github-actions[bot] edited this page Oct 31, 2025
·
1 revision
Desktop integration for opening files, URLs, and accessing system paths.
Overview
The Electron.Shell API provides system integration functionality for opening files and URLs with their default applications, managing trash/recycle bin, and creating/reading shortcut links.
Methods
🧊 void Beep()
Play the beep sound.
🧊 Task<string> OpenExternalAsync(string url)
Open the given external protocol URL in the desktop's default manner (e.g., mailto: URLs in the user's default mail agent).
Parameters:
url - Max 2081 characters on windows
Returns:
The error message corresponding to the failure if a failure occurred, otherwise empty string.
Creates or updates a shortcut link at shortcutPath.
Parameters:
shortcutPath - The path to the shortcut
operation - Default is ShortcutLinkOperation.Create
options - Structure of a shortcut
Returns:
Whether the shortcut was created successfully.
Usage Examples
File Operations
// Open file with default applicationvarerror=awaitElectron.Shell.OpenPathAsync(filePath);if(string.IsNullOrEmpty(error)){Console.WriteLine("File opened successfully");}else{Console.WriteLine($"Failed to open file: {error}");}// Show file in file managerawaitElectron.Shell.ShowItemInFolderAsync(filePath);// Move file to trashvartrashed=awaitElectron.Shell.TrashItemAsync(filePath);Console.WriteLine($"File trashed: {trashed}");
URL Operations
// Open URL in default browservarerror=awaitElectron.Shell.OpenExternalAsync("https://electron.net");if(!string.IsNullOrEmpty(error)){Console.WriteLine($"Failed to open URL: {error}");}// Open email clientawaitElectron.Shell.OpenExternalAsync("mailto:user@example.com");// Open with optionsvarerror=awaitElectron.Shell.OpenExternalAsync("https://example.com",newOpenExternalOptions{Activate=true});
System Integration
// Play system beepElectron.Shell.Beep();// Create desktop shortcutvarsuccess=awaitElectron.Shell.WriteShortcutLinkAsync(@"C:\Users\Public\Desktop\MyApp.lnk",ShortcutLinkOperation.Create,newShortcutDetails{Target="C:\\Program Files\\MyApp\\MyApp.exe",Description="My Application",WorkingDirectory="C:\\Program Files\\MyApp"});// Read shortcut informationvardetails=awaitElectron.Shell.ReadShortcutLinkAsync(@"C:\Users\Public\Desktop\MyApp.lnk");Console.WriteLine($"Target: {details.Target}");
Integration with Dialog API
// Use with file dialog resultsvarfiles=awaitElectron.Dialog.ShowOpenDialogAsync(window,options);if(files.Length>0){varselectedFile=files[0];// Open the selected fileawaitElectron.Shell.OpenPathAsync(selectedFile);// Show in file managerawaitElectron.Shell.ShowItemInFolderAsync(selectedFile);}