如何执行命令:
adb.exe kill-server
Run Code Online (Sandbox Code Playgroud)
对于位于解决方案本身的文件?
我在环境变量中将adb添加到PATH后才执行:
private string implementCommandLine(string fileName, string param)
{
string output = "";
ProcessStartInfo startInfo = new ProcessStartInfo(fileName, param)
{
WindowStyle = ProcessWindowStyle.Hidden,
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
CreateNoWindow = true
};
Process adbProc;
adbProc = Process.Start(startInfo);
using (StreamReader myOutput = adbProc.StandardOutput)
{
output = myOutput.ReadToEnd();
}
return output;
}
Run Code Online (Sandbox Code Playgroud)
我也试过获取位于Files文件夹中的adb.exe的路径
但是这条路真的太混乱了,我无法成功!
仍然当我执行"Files/adb.exe [params]"时,我收到此错误:
An unhandled exception of type 'System.ComponentModel.Win32Exception' occurred in System.dll
Run Code Online (Sandbox Code Playgroud)
例外细节:
您在解决方案资源管理器中看到的文件夹用于在您进行开发时组织源代码.通常,一旦构建并部署了程序,这些文件夹就不会自动具有任何意义.
您需要做的是确保您需要运行的文件是构建输出的一部分,您可以提前知道文件相对于可执行文件的位置,然后确保以这种方式部署它.最简单的方法是在感兴趣的项目上设置属性:
这将完整地将项目复制到与源代码相同的文件夹结构中的构建输出中,因此在您的情况下,您的Debug文件夹将具有:
Program.exe Program.pdb Files\adb.exe
无论何时部署构建,请确保维护该文件夹结构,然后您可以找到adb.exe相对于Program.exe使用任何常用方法获取程序的文件夹路径,
| 归档时间: |
|
| 查看次数: |
177 次 |
| 最近记录: |