Skip to content

Commit 4b5494e

Browse files
committed
Added FileResult for iOS and MacCatalyst. Fixes #1
1 parent 6ad55ea commit 4b5494e

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

LukeMauiFilePicker/FilePickerService.MaciOS.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,18 @@ public partial async Task<bool> SaveFileAsync(SaveFileOptions options)
6060
await options.Content.CopyToAsync(file);
6161
}
6262
var url = new NSUrl(path, false);
63-
63+
6464
var picker = new UIDocumentPickerViewController(new[] { url });
6565
TaskCompletionSource<bool> filesTcs = new();
6666
picker.DidPickDocumentAtUrls += (_, e) =>
6767
{
6868
filesTcs.TrySetResult(e.Urls.Length > 0);
6969
};
70-
70+
7171
var controller = Platform.GetCurrentUIViewController();
7272
ArgumentNullException.ThrowIfNull(controller);
7373
await controller.PresentViewControllerAsync(picker, true);
74-
74+
7575
return await filesTcs.Task;
7676
}
7777

@@ -84,10 +84,9 @@ public IosFile(NSUrl url)
8484
this.url = url;
8585
}
8686

87-
public string FileName
88-
=> Path.GetFileName(url.Path!);
87+
public string FileName => url.Path is null ? "" : Path.GetFileName(url.Path);
8988

90-
public FileResult? FileResult => null;
89+
public FileResult? FileResult => url.Path is null ? null : new(url.Path);
9190

9291
public Task<Stream> OpenReadAsync()
9392
=> Task.FromResult(new FileStream(url.Path!, FileMode.Open) as Stream);

0 commit comments

Comments
 (0)