我使用VS 2017,我需要从其他应用程序接收图像。所以它基本上是App-App通信。我是UWP和Windows Mobile开发人员的新成员,所以我研究了很多,并且设法使用共享内容获取DataPackage。Reciving Image-UWP
当您尝试来研究这个:
if (this.shareOperation.Data.Contains(StandardDataFormats.Bitmap))
{
this.sharedBitmapStreamRef = await this.shareOperation.Data.GetBitmapAsync();
//catch (Exception ex)
//{
// NotifyUserBackgroundThread("Failed GetBitmapAsync - " + ex.Message, NotifyType.ErrorMessage);
//}
}
问题是,应用程序不会看到我的文件作为位图。 当我尝试获取recived文件的类型时,它给了我System .__ COMObject。 我管理获取文件作为storageitem,但我无法读取IRandomAccessStreamReference。 As StorageItem I get,path,name etc.
ShareTarget示例应用程序发生同样的事情,它也不会将图像视为BitMap(formatId)。 有什么建议吗?
那么,为什么不加载StorageItem到BitmapImage的? –
ShareSource是否使用'DataPackage.SetBitmap'方法设置DataPackage中包含的位图图像?如果是这样,ShareOperation.Data.Contains(StandardDataFormats.Bitmap)将返回'true'。你也可以检查什么是StandardDataFormats类型。 –
@IgorKulman我从图库或文件资源管理器共享数据。我通过从IStorageItem中读取路径来加载BitmapImage,然后创建一个StorageFIle。我的下一个问题是,它只有在文件位于图片(内部存储)文件夹中才有效。我也增加了打开pdf的可能性。并在.pdf文件位于图片文件夹中时打开。我现在正在寻找我需要什么权限以及如何实现文件类型关联。有什么建议么? –