亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

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 關注
  • 105 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號