C# 使用c获取apk信息#
我想获得apk文件的内部名称,我尝试了很多方法,搜索了很多。最后,我得到的是:C# 使用c获取apk信息#,c#,android,apk,C#,Android,Apk,我想获得apk文件的内部名称,我尝试了很多方法,搜索了很多。最后,我得到的是: Process proc = new Process(); proc.StartInfo.FileName = "cmd.exe"; proc.StartInfo.RedirectStandardInput = true; proc.StartInfo.RedirectStandardOutput = true; proc.StartIn
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
获取输出?
我试过按参数运行process,结果很糟糕:)apk文件只是zip文件,您可以在不调用外部EXE的情况下处理它们。看看这门课。@Lucastzesniewski我知道。有一个名为manifest.xml的xml文件,其中包含我需要的信息。但首先它是编码的,不容易解码,但主要问题是字符串在一个单独的文件中,清单文件中唯一的东西是该文件中的引用(更糟糕的是,引用只是一个数字)。考虑到这种复杂性,我想最好使用aapt.exe。(所有相关软件都做相同的事情)