Today I share with you a small (but useful) piece of code .
Indeed, for now WinRT does not provide a method to test the existence of a specific file. You can only try/catch an GetFileAsync call and it can be disappointing.
So here is a little solution:
public async static Task<bool> FileExistsAsync(this StorageFolder folder, string name)
var files = await folder.GetFilesAsync();
return f.Name == name;
To use it, just call the following code:
if (!await ApplicationData.Current.LocalFolder.FileExistsAsync(filename))
StorageFile file = await ApplicationData.Current.LocalFolder.GetFileAsync(filename);