WebExeBuilder Documentation

showInExplorer

Category: Shell Operations

Namespace: web.shell.showInExplorer

Description

Opens Windows Explorer and shows the specified file or folder. For files, the file is selected in Explorer. For folders, the folder is opened.

Syntax

const success = await web.shell.showInExplorer({
    filePath: 'C:\\Documents\\report.pdf'
});

Parameters

  • filePath (required) - Path to the file or folder to show in Explorer

Returns

Promise<boolean> - Returns a promise that resolves with true if successful, false with error message otherwise

Examples

Show file in Explorer

const success = await web.shell.showInExplorer({
    filePath: 'C:\\Documents\\report.pdf'
});

if (success) {
    console.log('File shown in Explorer');
}

Open folder in Explorer

const success = await web.shell.showInExplorer({
    filePath: 'C:\\Projects\\MyApp'
});

if (success) {
    console.log('Folder opened in Explorer');
}

Show downloaded file

// After downloading a file, show it to the user
const result = await web.files.downloadFromUrl({
    url: 'https://example.com/file.zip',
    filePath: 'C:\\Downloads\\file.zip',
    overwrite: true
});

if (result.success) {
    // Show the downloaded file in Explorer
    await web.shell.showInExplorer({
        filePath: result.filePath
    });
}

Show application directory

// Show the application's directory
const appDir = await web.directory.getAppExeDir();
await web.shell.showInExplorer({
    filePath: appDir
});

Use Cases

  • Show downloaded files to users
  • Let users browse to a specific file location
  • Open folders for user exploration
  • Reveal generated or exported files
  • Show application installation directory

Notes

  • Verifies the path exists before attempting to open Explorer
  • For files: Opens Explorer with the file selected (using /select parameter)
  • For folders: Opens the folder directly in Explorer
  • Returns error if the path doesn't exist
  • Works with both files and directories
  • Uses Windows explorer.exe command
  • Returns detailed error messages for common failures