0

On C#, raspberry, windows IOT, The app stop on this line

StorageFile file = await storageFolder.GetFileAsync("Signature.jpg", 
    CreationCollisionOption.ReplaceExisting);

I get this error :

an item cannot be found at the specified path

But Signature.jpg is on this folder existing

Thanks for your help,

Rita Han
  • 9,574
  • 1
  • 11
  • 24
djillius
  • 23
  • 8

1 Answers1

0

I can also reproduce this issue when access the shared file on a computer from Windows 10 IoT core.

The workaround for this issue is that you can setup a web server to share the file instead of using file sharing. For example, I setup the IIS on my computer and copy the signature.jpg to the root folder of IIS(C:\inetpub\wwwroot). Then we can use the code below download the file from IIS:

    async void DownloadImageAndDisplay()
    {
        Uri fileUri = new Uri("http://{AddressOfPC}/signature.jpg");
        IRandomAccessStreamReference thumbnail =
RandomAccessStreamReference.CreateFromUri(fileUri);
       StorageFile imageFile=await StorageFile.CreateStreamedFileFromUriAsync("signature.jpg", fileUri, thumbnail);

        BitmapImage bitmapImage = new BitmapImage();
        Windows.Storage.Streams.RandomAccessStreamOverStream stream = (Windows.Storage.Streams.RandomAccessStreamOverStream)await imageFile.OpenAsync(FileAccessMode.Read);
        bitmapImage.SetSource(stream);
        image.Source = bitmapImage;
    }
Fei Xue
  • 14,369
  • 1
  • 19
  • 27