英文:
How to send/share data between an Electron app and UWP app
问题
我有一个用例,需要能够从Electron应用程序向UWP(gamebar)应用程序发送数据(图像和可能一些JSON元数据)。
显而易见的解决方案似乎是从Electron将数据写入本地磁盘文件,然后从UWP应用程序中读取它。我遇到的问题是,即使在我的UWP应用程序中启用了<rescap:Capability Name="broadFileSystemAccess"/>
,用户仍然需要在Windows设置中显式启用文件访问权限,以便我的UWP应用程序能够从任意位置的磁盘上读取文件。
是否有一种方法可以在这个问题上实现应用程序之间的进程间通信?
英文:
I have a usecase where I need to be able to send data (images and maybe some json metadata) from an electron app to a UWP (gamebar) app.
The obvious answer to this would seem to be writing data to a local file on disc from Electron, and reading it from the UWP app. The issue I'm having there is that even with <rescap:Capability Name="broadFileSystemAccess"/>
enabled in my UWP app, the user would have to explicitly enable file access for this app in their Windows settings in order for my UWP app to be able to read a file from an arbitrary location on disc.
Is there a way to have inter-process communication between the apps to get around this issue?
答案1
得分: 1
你可以尝试将文件保存到文档库中,只要在清单文件中添加了documentsLibrary
权限,文档库默认已启用。
StorageFolder folder = KnownFolders.DocumentsLibrary;
StorageFile file = await folder.GetFileAsync("paris.png");
如果您不想使用文件系统进行IPC,您可能需要在此处检查其他方法:UWP-ipc
英文:
You could try to save the file into the Document library which is enabled by default as long as you added the documentsLibrary
capability in the manifest file.
StorageFolder folder = KnownFolders.DocumentsLibrary;
StorageFile file = await folder.GetFileAsync("paris.png");
If you don't want to use file system to do the IPC, you might need to check other ways here: UWP-ipc
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论