Hi all,
I'm currently trying to display an Image
that is being saved to the StorageFolder
of the App on Windows Phone. I'm using DependecyService
to Save the Image
, which is working on all three platforms. However I'm not able to display the Image
on WinPhone
, while on Android and iOS it is working as expected.
I hope someone here has an idea. Here's my simplified code
//Page where Image is displayed
public class ShowImagePage : ContentPage
{
ShowImagePage()
{
//Initialize view and controls
//Set ImageSource
var storage = DependecyService.Get<IStorage>();
logo.Source = ImageSource.FromFile(storage.GetLogo(filename));
//Add logo to StackLayout and stuff
}
}
Here is the code from the Platform projects
//On Android
public string GetLogo(string fileName)
{
var directory = Enviroment.GetFolderPath(Enviroment.SpecialFolder.Personal);
return Path.Combine(directory, fileName);
}
//On iOS
public string GetLogo(string fileName)
{
var directory = Enviroment.GetFolderPath(Enviroment.SpecialFolder.Personal);
return Path.Combine(directory, fileName + ".png");
}
//On WinPhone
public string GetLogo(string fileName)
{
GetFileInfo(fileName);
//Private property
return _filePath;
}
private async void GetFileInfo(string fileName)
{
var fileInfo = await ApplicationData.Current.LocalFolder.GetFileAsync(fileName);
_filePaht = fileInfo.Path;
}
So on WinPhone I'm getting the complete path to the Image. Which looks like this:
fileInfo.Path = "C:\Data\Users\DefApps\AppData\Local\Packages\5fefb51f-e540-47c1-8b17-151ab4b91e99_fhz98wmef0kew\LocalState\IMG_20150928_111909.jpg"
But the Image isn't getting displayed. Fun fact: Deleting the Image from the StorageFolder is no Problem.
I hope someone can help me here