I have tried many ways to set image source to a network directory in my UWP application. For example I have tried this example:
BitmapImage bitmap = new BitmapImage(new Uri(@"\\venera\Mariner\747\03_WEDNESDAY\003\00 Flat B -\APR3783216-MED-BLK TAPE-GB-Apron.jpg"));
UserImage.Source = bitmap;
and
bitmap.UriSource = new Uri(@"\\venera\Mariner\747\03_WEDNESDAY\003\00 Flat B -\APR3783216-MED-BLK TAPE-GB-Apron.jpg", UriKind.Absolute);
UserImage.Source = bitmap;
But none of them works. I ended up with the following error E_NETWORK_ERROR
I have read many links from stackoverflow and from other resource but there is not any thing which works for me.
I have set required capabilities and declarations for it.
I have tried it with Windows.Storage.Pickers.FolderPicker
but I couldn't find any thing where I can set the folder location where to read files.
I don want to open folder picker, I just want to get images directly from a specified location of network.
May be some you try to relate it with this ticket How to display an image from a network folder or local drive in a Windows Universal App but this is not helping me in my task.
I also have tried these examples for me but still couldn't achieve the target: https://docs.microsoft.com/en-us/windows/uwp/files/quickstart-managing-folders-in-the-music-pictures-and-videos-libraries
https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.controls.image
I am getting System.UnauthorizedAccessException: 'Access is denied.
Error
You can't use any path. Only KnownFolders and local app path. But you may get array of bytes from anywhere:
To set a .jpg file in shared folder on network, we can get the
StorageFile
first and then use theSetSource
method to set the source to theBitmapImage
. To access files in the shared folder, we need declare some capabilities in the app manifest.Universal Naming Convention (UNC) is the naming system commonly used in Microsoft Windows for accessing shared network folders. For more info, please refer File access permissions.
This is my Package.appxmanifest:
The code of setting BitmapImage: