WPF-包含具有Clickonce部署的许多文件的附件文件夹,该文件夹将安装在用户C驱动器中

时间:2019-11-23 09:59:09

标签: wpf clickonce

我正在开发WPF应用程序,它具有在用户pc中运行“ CMD”并导航到应用程序文件中包含的一个文件夹“ platform-tools”并执行命令的功能。

string Request = " /c" + "cd../../&cd platform-tools& adb reboot ";
 Process procc = new Process();
 ProcessStartInfo procStartInfo2 = new ProcessStartInfo(@"cmd.exe", Request);

我们知道,当用户在PC上安装应用程序时,该应用程序将位于C:\ Users \“” UserName \ AppData \ Local \ Apps \ 2.0 \“随机名称,例如:JBJHV6HG7HG 因此很难知道“平台工具”的确切安装位置。

我的问题是:有什么办法可以通过“请求”知道如何到达Platform-tools文件夹,以便执行adb命令?

有没有办法在“用户的桌面”等不同位置安装“平台工具”,然后我可以在CMD中更改“ CD”命令以导航到用户的桌面或C驱动器?

1 个答案:

答案 0 :(得分:1)

使用ClickOnce,由于某些安全功能等原因,您将无法更改目标安装文件夹。 您可以找到更多的Here

您可以获得执行过程的路径,并连接文件夹名称以到达“ platform-tools”文件夹:

       //There's two ways to get the current file address from your application (in the end both ends in the same):

          //There's two ways to get the current file address from your application (in the end both ends in the same):

        //getting the filename by the process
        var cc = Process.GetCurrentProcess().MainModule.FileName;
        //getting the filename by the executing assembly
        var dd = System.Reflection.Assembly.GetExecutingAssembly().Location;

        //getting the path for that file name
        string assemblyPath = Path.GetDirectoryName(cc);


        var platformTools = string.Concat(assemblyPath, @"/platform-tools/someprocess.exe");
        Process.Start(platformTools);
相关问题