public override async Task <StorageFile> GetFileAsync(string name, CancellationToken token) { await TryInitializeStorage(); var filePath = IOPath.Combine(Path, name); if (!File.Exists(filePath)) { throw new FileNotFoundException(filePath); } return(StorageFile.GetFileFromPath(filePath)); }
public IAsyncOperation <StorageFile> GetFileAsync(string path) => AsyncOperation.FromTask(async ct => { await TryInitializeStorage(); var filePath = global::System.IO.Path.Combine(Path, path); if (!File.Exists(filePath)) { throw new FileNotFoundException(filePath); } return(StorageFile.GetFileFromPath(filePath)); });
public override async Task <StorageFile> GetFileAsync(string name, CancellationToken token) { await TryInitializeStorage(); var filePath = IOPath.Combine(Path, name); if (Directory.Exists(filePath)) { throw new ArgumentException($"The item with name '{name}' is a folder.", nameof(name)); } if (!File.Exists(filePath)) { throw new FileNotFoundException($"There is no file with name '{name}'."); } return(StorageFile.GetFileFromPath(filePath)); }