在C#,覆盆子,Windows IOT, 应用程序在此行上停止
StorageFile file = await storageFolder.GetFileAsync("Signature.jpg",
CreationCollisionOption.ReplaceExisting);
我收到此错误:
在指定路径下找不到项目
但是Signature.jpg在此文件夹中已存在
感谢您的帮助,
答案 0 :(得分:0)
从Windows 10 IoT核心版访问计算机上的共享文件时,我也可以重现此问题。
此问题的解决方法是您可以设置Web服务器来共享文件,而不是使用文件共享。例如,我在计算机上安装IIS,然后将signature.jpg复制到IIS的根文件夹(C:\ inetpub \ wwwroot)。然后,我们可以使用下面的代码从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;
}