我想获取apk文件的内部名称,我尝试了很多方法,并且我搜索了很多。最后这就是我所拥有的:
Process proc = new Process();
proc.StartInfo.FileName = "cmd.exe";
proc.StartInfo.RedirectStandardInput = true;
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.StandardOutputEncoding = System.Text.Encoding.UTF8;
proc.Start();
using (StreamWriter sw = proc.StandardInput)
{
foreach (string path in Directories.GetAllFiles(@"E:\apk", "apk"))
{
sw.WriteLine("aapt d badging " + "\"" + path + "\"");
//following line doesn't work because sStandardInput is open
Debug.WriteLine(proc.StandardOutput.ReadToEnd());
}
}
// There will be a really huge amount of text (at least 20 line per sw.Writeline) and
//it impacts performance so following line is not really what I'm looking for
Debug.WriteLine(proc.StandardOutput.ReadToEnd());
GetAllFiles
是我创建的一个函数,用于获取所有apk文件的完整路径。这不是最终代码
正如我先评论它Debug.WriteLine
不起作用,第二个不是一个好主意。我该如何从proc
获得输出?
我试过通过参数运行proccess并且它很可怕:)