-1

I am using the BitmapImage to set the image source. I tried

https://learn.microsoft.com/en-us/dotnet/framework/wpf/graphics-multimedia/how-to-use-a-bitmapimage

this way to set the local folder image to BitmapImage source, but the image not loaded.

Anyone, please help me how to set the local folder images to an image source (I want this image "C:\Users\Name\Pictures\CusotmViewImage1.png and tried

bitmap.UriSource = new Uri(@"C:\Users\santhiya.arulsamy\Pictures\CusotmViewImage1.png" 

like this);

demonplus
  • 5,613
  • 12
  • 49
  • 68
Santhiya
  • 191
  • 2
  • 14
  • Possible duplicate of [UWP - Image Uri in Application Folder](https://stackoverflow.com/questions/32314799/uwp-image-uri-in-application-folder) – demonplus Dec 21 '18 at 09:12
  • Please also note that UWP and WPF are completely different, folders you can reach in UWP are very limited – demonplus Dec 21 '18 at 09:13

1 Answers1

1

UWP is a sandboxed platform, making it unable to directly access the file. What you should do instead is by using StorageFile and StorageFolder class to access those files by using Files/Folders picker and implement it behind the page (*.xaml.cs).

Another way to access it is by using a property in the static class windows.storage.knownfolders and use the method GetFileAsync(),like this one for example. But keep it mind to add a capability in your app configuration. In your case, you can use windows.storage.knownfolders.pictureslibrary property, add picturesLibrary capability in your app configuration, and get the file by using the method mentioned above.

Little doe
  • 184
  • 2
  • 10