I write a Windows 10 Universal App like the default Photo App in C#. The Photo App allows to show all images in the directory where the user opened the file with the Photo App. But when the user opened a file with my App I get only the FileActivatedEventArgs with allows to display the file the user opened. I found no solution to show the user the other files from the directory of this file too. I think the problem is to get the permission to access that files because when the folder of the file is in the picture library it works. But the Windows Photo App can this everywhere so I think there must be a solution ...
Edit: I have tried to extract a very simple sample code from my project that show the relevant part in only a few lines of code
public static async Task<BitmapImage> LoadImage(StorageFile file)
{
BitmapImage bitmapImage = new BitmapImage();
FileRandomAccessStream stream = (FileRandomAccessStream)await file.OpenAsync(FileAccessMode.Read);
bitmapImage.SetSource(stream);
return bitmapImage;
}
private async void setImages(FileActivatedEventArgs args)
{
StorageFile si = (StorageFile)App.args.Files.First();
StorageFolder st = await si.GetParentAsync();
StorageApplicationPermissions.FutureAccessList.Add(st);
IReadOnlyList<StorageFile> sflist = await st.GetFilesAsync();
foreach (StorageFile sf in sflist)
{
imageList.Add(await LoadImage(sf));
}
}