简体   繁体   中英

an item cannot be found at the specified path

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,

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;
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM