Before Windows 8, to check a file exist or not on Windows Phone 7.5 or .NET can be as simple as calling the file.IsFileExist() and it will return a simple boolean indicated whatever the file exist or not. But Windows 8 team decided to have a totally different way and I had no idea why Microsoft or Windows 8 team decided to re-write it.
Anyway, here is how it work out in Windows 8 app (C# code):
public async Task<bool> IsFileExist(string path) { try { await Windows.Storage.StorageFile.GetFileFromPathAsync(path); // file found return (true); } catch { // file not found return (false); } }
by Ooi Keng Siang via Ooiks’s Blog
why catch target expcetion type is not exist.
LikeLike