
Untitled
By: a guest on
Jan 4th, 2013 | syntax:
None | size: 0.97 KB | hits: 21 | expires: Never
Using System.IO
... lost of code
privat void share()
....
if (File.exist(filename)
{
add file to share
}
StorageFile file;
try {
file = await ApplicationData.Current.LocalStorage.GetFileAsync("foo.txt");
}
catch (FileNotFoundException) {
file = null;
}
public static async Task<bool> FileExistsAsync(this StorageFolder folder, string fileName)
{
try
{
await folder.GetFileAsync(fileName);
return true;
}
catch (FileNotFoundException)
{
return false;
}
}
var sourceFolder = Windows.ApplicationModel.Package.Current.InstalledLocation;
sourceFolder = await sourceFolder.GetFolderAsync("Assets");
var files = await sourceFolder.GetFilesAsync();
var requiredFiles = new List<String> { "ThisWorks.png", "NotHere.png" };
foreach(var filename in requiredFiles)
{
// your example logic here...
Debug.WriteLine(filename + " " + (files.Any(f => f.Name == filename) ? "Exists" : "Doesn't exist"));
}