我有这个代码,我正在尝试运行Python脚本。当我通过命令提示符手动执行它时,它可以正常工作,但如果我尝试通过单击C#Windows窗体中的按钮来执行此操作,则无法正常工作。
private void btnGenerateAndrowarn_Click(object sender, EventArgs e) {
string[] filePaths = Directory.GetFiles(@"C:\Users\User1\Desktop\Android Tools\androwarn\Samples", "*.apk");
foreach (string fileName in filePaths) {
ProcessStartInfo startInfo;
Process process;
string directory = @"C:\Users\User1\Desktop\Android Tools\androwarn\";
string script = "androwarn.py";
startInfo = new ProcessStartInfo("python");
startInfo.WorkingDirectory = directory;
startInfo.Arguments = directory + script + " -i " + fileName + " -r html -v 3";
startInfo.UseShellExecute = false;
startInfo.CreateNoWindow = true;
startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardError = true;
process = new Process();
process.StartInfo = startInfo;
process.Start();
}
}
答案 0 :(得分:0)
最有可能的是,python
不在您的%PATH%中。