为了账号安全,请及时绑定邮箱和手机立即绑定

UWP 可以使用 StorageFile 运行进程吗?

UWP 可以使用 StorageFile 运行进程吗?

C#
qq_笑_17 2023-05-13 16:01:31
有这个代码:StorageFolder storageFolder = await StorageApplicationPermissions.FutureAccessList.GetFolderAsync(file.folderToken);            StorageFile storageFile = await storageFolder.CreateFileAsync("run.exe", CreationCollisionOption.ReplaceExisting);await FileIO.WriteBytesAsync(storageFile, Properties.Resources.youtube_dl1);我可以使用文件夹令牌在用户选择的位置创建一个文件。我现在想在一个进程中运行该文件:Process checkforupdates = new Process();checkforupdates.StartInfo.FileName = storageFile.Path;checkforupdates.StartInfo.Arguments = "-x https://www.youtube.com/watch?v=uzr5jm9ueja";checkforupdates.StartInfo.UseShellExecute = false;checkforupdates.StartInfo.RedirectStandardOutput = true;checkforupdates.StartInfo.RedirectStandardOutput = true;checkforupdates.StartInfo.RedirectStandardError = true;checkforupdates.StartInfo.CreateNoWindow = true;checkforupdates.EnableRaisingEvents = true;checkforupdates.OutputDataReceived += (s, er) =>{Debug.WriteLine("dsds" + er.Data);};checkforupdates.Start();checkforupdates.BeginOutputReadLine();checkforupdates.BeginErrorReadLine();checkforupdates.WaitForExit();  如果我使用,这很好用: StorageFolder storageFolder = ApplicationData.Current.LocalFolder;但只要我使用用户选择的文件夹,我就会收到异常。我确定异常是 UnauthorizedAccessException 但我需要一个 bunlded exe 在文件夹内解压缩,然后运行命令以在用户选择的文件夹内生成文件。在执行此操作时,我需要解析正在运行的命令行实用程序的输出。有什么办法吗?
查看完整描述

1 回答

?
万千封印

TA贡献1891条经验 获得超3个赞

您可以通过“桌面桥”将 Win32 应用程序打包到 UWP 应用程序包中,然后使用 FullTrustProcessLauncher 运行并通过应用程序服务与其通信。


查看完整回答
反对 回复 2023-05-13
  • 1 回答
  • 0 关注
  • 65 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信