WindowsPhone Silverlight:
IsolatedStorageFile.FileExists("FileName");WindowsPhone Store(WinRT):
In WindowsPhone store 8.1 ,We will use the GetFileAsync function, this function returns the file data if it exists, throwing an exception if it does not exist.
In WindowsPhone store 8.1 ,We will use the GetFileAsync function, this function returns the file data if it exists, throwing an exception if it does not exist.
public static async Task < bool > FileExists ( this StorageFolder folder, String filepath)
{
#if WINDOWS_APP
return await folder.TryGetItemAsync (filepath)! = null ;
#endif
#if WINDOWS_PHONE_APP
try
{
await folder.GetFileAsync (filepath);
return true ;
}
catch
{
return false ;
}
#endif
}