private/Get-SplitterUiSourceIsoPath.ps1
|
function Get-SplitterUiSourceIsoPath { [CmdletBinding()] param( [Parameter(Mandatory)] [object] $Window, [string] $InitialPath ) $options = [GliderUI.Avalonia.Platform.Storage.FilePickerOpenOptions]::new() $options.Title = 'Select Source ISO' $options.AllowMultiple = $false if (-not [string]::IsNullOrWhiteSpace($InitialPath)) { try { $parentDirectory = Split-Path -Path $InitialPath -Parent if (-not [string]::IsNullOrWhiteSpace($parentDirectory) -and (Test-Path -LiteralPath $parentDirectory)) { $directoryUri = [System.Uri]::new($parentDirectory) $options.SuggestedStartLocation = $Window.StorageProvider.TryGetFolderFromPathAsync($directoryUri).WaitForCompleted() } } catch { # Ignore start location errors and continue with the platform default picker location. } } $files = $Window.StorageProvider.OpenFilePickerAsync($options).WaitForCompleted() $selectedFile = @($files) | Select-Object -First 1 if ($null -eq $selectedFile) { return $null } if ($null -eq $selectedFile.Path) { return $null } [System.Uri]::UnescapeDataString($selectedFile.Path.AbsolutePath) } |