public async Task Add(PickedFile file) { IStorageFile f = null; if (file.Source == PickedFileSource.Local) { f = await StorageFile.GetFileFromPathAsync(file.Path); } else if (file.Source == PickedFileSource.Uri) { var uri = new Uri(file.Path); f = await StorageFile.CreateStreamedFileFromUriAsync(Path.GetFileName(file.Path), uri, RandomAccessStreamReference.CreateFromUri(uri)); } else { throw new ArgumentException("Unknown File source.", nameof(f)); } lock (syncObject) { if (fileOpenPickerUI.CanAddFile(f)) { fileOpenPickerUI.AddFile(file.Path, f); } } }
public async Task Remove(PickedFile file) { lock (syncObject) { if (fileOpenPickerUI.ContainsFile(file.Path)) { fileOpenPickerUI.RemoveFile(file.Path); } } await Task.CompletedTask; }