Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jan 4th, 2013  |  syntax: None  |  size: 0.97 KB  |  views: 21  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Using System.IO
  2.  ... lost of code
  3. privat void share()
  4. ....
  5.     if (File.exist(filename)
  6.     {
  7.        add file to share
  8.     }
  9.        
  10. StorageFile file;
  11. try {
  12.     file = await ApplicationData.Current.LocalStorage.GetFileAsync("foo.txt");
  13. }
  14. catch (FileNotFoundException) {
  15.     file = null;
  16. }
  17.        
  18. public static async Task<bool> FileExistsAsync(this StorageFolder folder, string fileName)
  19. {
  20.     try
  21.     {
  22.         await folder.GetFileAsync(fileName);
  23.         return true;
  24.     }
  25.     catch (FileNotFoundException)
  26.     {
  27.         return false;
  28.     }
  29. }
  30.        
  31. var sourceFolder = Windows.ApplicationModel.Package.Current.InstalledLocation;
  32. sourceFolder = await sourceFolder.GetFolderAsync("Assets");
  33. var files = await sourceFolder.GetFilesAsync();
  34. var requiredFiles = new List<String> { "ThisWorks.png", "NotHere.png" };
  35. foreach(var filename in requiredFiles)
  36. {
  37.     // your example logic here...
  38.     Debug.WriteLine(filename + " " + (files.Any(f => f.Name == filename) ? "Exists" : "Doesn't exist"));
  39. }
clone this paste RAW Paste Data