top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

WP Silverlight vs Universal Apps : Check file exist in Local Storage C#?

+2 votes
72 views
WP Silverlight vs Universal Apps : Check file exist in Local Storage C#?
posted Feb 27, 2015 by Puhal

Share this question
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button

1 Answer

+1 vote
 
Best answer

When we move from Silverlight to WinRT can feel some gaps, especially when trying to check if a file exists or not in the isolated / local storage.

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.

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    
}    
answer Mar 3, 2015 by Jdk
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...