예제 #1
0
            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));
            }
예제 #2
0
        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));
        });
예제 #3
0
            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));
            }