我有一個代碼歸檔ZIP文件到另一個ZIP文件,使用命令如下:命令WinRAR的對特定文件
String rootftp = "C:\\ROOT_DIR_PUSHFILE\\";
String tampungString = "AAA\\PFILE\\AAA20140531.zip";
String password = "testing";
String command = "cmd.exe "
+ "/C"
+ " cd C:\\Program Files\\WinRAR \n"
+" && rar a -n "+rootftp.trim()+tampungString+".zip"+" "+ rootftp.trim()+tampungString + " -p"+password.trim();
System.out.println(command);
File file = new File(rootftp.trim()+tampungString);
try {
Runtime.getRuntime().exec(command);
file.delete();
} catch (Exception e) {
System.out.println(e);
e.printStackTrace();
}
但結果是:
當我試着歸檔一個特定的文件,結果總是從根目錄歸檔,而不僅僅是特定的文件,比如AAA20140531.zip文件,你能解釋一下,爲什麼?以及如何解決它?
你知道家用機版'Rar.exe'支持只壓縮和提取RAR檔案?因此,即使在命令行中指定'.zip',創建的存檔文件仍然是RAR存檔而不是ZIP存檔。在WinRAR的程序文件文件夾中讀取文件'Rar.txt'頂部的介紹。只有GUI版本的WinRAR.exe支持ZIP壓縮/提取。 – Mofi