private static void RenameSubFiles(DirectoryInfo value, string startAppend) { FileInfo[] fileInfos = value.GetFiles(); foreach (FileInfo fileInfo in fileInfos) { ApkProcessLogic.OutPut("【I】" + fileInfo.DirectoryName + "\\" + fileInfo.Name + " 重命名为:" + startAppend + fileInfo.Name); string preName = fileInfo.DirectoryName + "\\" + fileInfo.Name; string newName = fileInfo.DirectoryName + "\\" + startAppend + fileInfo.Name; File.Move(preName, newName); } }
public static void DeletDir(string UnpackPath, string relativePath) { String dir = UnpackPath + "\\" + relativePath; if (Directory.Exists(dir)) { ApkProcessLogic.OutPut("【I】---------------------------"); ApkProcessLogic.OutPut("【I】删除" + relativePath + "所在目录 " + dir); Directory.Delete(dir, true); } }
public static void DeletFile(string UnpackPath, string relativePath) { String file = UnpackPath + "\\" + relativePath; if (File.Exists(file)) { ApkProcessLogic.OutPut("【I】---------------------------"); ApkProcessLogic.OutPut("【I】删除" + relativePath); File.Delete(file); } }
public static void RenameFile(string UnpackPath, string relativePath, string newRelativePath) { String file = UnpackPath + "\\" + relativePath; String newfile = UnpackPath + "\\" + newRelativePath; if (File.Exists(newfile)) { File.Delete(newfile); } if (File.Exists(file)) { ApkProcessLogic.OutPut("【I】---------------------------"); ApkProcessLogic.OutPut("【I】重命名AndroidManifest.xml为manifest.txt"); File.Move(file, newfile); } }
public static void MoveDir(string source, string dest) { if (File.Exists(dest)) { Directory.Delete(dest, true); } string destParentDir = dest.Substring(0, dest.LastIndexOf("\\")); checkDir(destParentDir); if (Directory.Exists(source)) { ApkProcessLogic.OutPut("【I】---------------------------"); ApkProcessLogic.OutPut("【I】移动目录" + source + " -> " + dest); Directory.Move(source, dest); } }
public static void CopyFile(string source, string dest) { if (File.Exists(dest)) { File.Delete(dest); } string destDir = Path.GetDirectoryName(dest); checkDir(destDir); if (File.Exists(source)) { ApkProcessLogic.OutPut("【I】---------------------------"); ApkProcessLogic.OutPut("【I】复制文件" + source + " -> " + dest); File.Copy(source, dest, true); } }
static void Main(String[] args) { //args = new String[] { @"G:\sc\桌面快捷存储\其他\20190218\ltsdk_18_v2.6.7_lenovo.apk" }; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); UpdateTool.AutoUpdate(); // 应用自动检测更新 Apk2Resource.DependentFiles.checksAll(); // 检测工具运行依赖文件 if (args != null && args.Length > 0) { string files = ApkProcessLogic.ArrayToStr(args); MainFrom.Apk2ResourceLogic(files); // 执行apk修改逻辑 } else { Application.Run(new MainFrom()); // 显示修改工具主界面 } }
private static void RenameValues(String UnpackPath) { string resDir = UnpackPath + "\\res"; ApkProcessLogic.OutPut("【I】---------------------------"); ApkProcessLogic.OutPut("【I】重命名" + resDir + "\\value目录下所有文件"); if (Directory.Exists(resDir)) { DirectoryInfo dir = new DirectoryInfo(resDir); DirectoryInfo[] valueDirs = dir.GetDirectories(); foreach (DirectoryInfo value in valueDirs) { string name = value.Name; if (name.Equals("values") || name.StartsWith("values-")) { RenameSubFiles(value, "ltsdk_"); } } } }
private static void OutPut(String info) { ApkProcessLogic.OutPut(info); }
public static void Apk2ResourceLogic(String sourceApks) { // 执行apk修改逻辑 ApkProcessLogic.Modify_Click(null, null, null, sourceApks, "", Modify_Logic); }
private void Modify_Click(object sender, EventArgs e) { // 执行apk修改逻辑 ApkProcessLogic.Modify_Click(this, Modify, richTextBox1, dirDest.Text, comboBox_sign.Text, Modify_Logic); }
private void dirDest_DragDrop(object sender, DragEventArgs e) { ApkProcessLogic.Form_DragDrop(sender, e); }
private void MainFrom_Load(object sender, EventArgs e) { ApkProcessLogic.loadSigns(comboBox_sign); // 载入签名文件信息 }