そのため、フォルダー内のファイルを検出し、特定の年齢になった後に体系的に圧縮するコードの小さなチャンクがあります。私は現在、ソフトウェアで使用するためにユーザーの要求に応じて特定の日付範囲のファイルを解凍するためのコードに取り組んでいます。
私の問題は、ファイルを圧縮するためのコマンドライン文字列がうまく機能することですが、解凍はうまくいきません...以下は、解凍方法を示すコードの抜粋です。確実に解凍するにはどうすればよいか教えてください。ありがとう!
private void UnZipFile()
{
if (myRecord == null)
{
if (File.Exists(zipInfo.FullName))
{
Process LogUnzipper = new Process();
//32-bit system
if (File.Exists("c:\\Program Files\\WinZip\\WZZIP.exe"))
{
//WZZIP.exe being the WinZip executable
LogUnzipper.StartInfo.FileName = "c:\\Program Files\\WinZip\\WZZIP.exe";
}
//64-bit system
else if (File.Exists("c:\\Program Files (x86)\\WinZip\\WZZIP.exe"))
{
//WZZIP.exe being the WinZip executable
LogUnzipper.StartInfo.FileName = "c:\\Program Files (x86)\\WinZip\\WZZIP.exe";
}
//here is where I think I'm screwing up something..
string action = "-e " + "\"" + zipInfo.FullName + "\"" + " \"" + zipInfo.DirectoryName + "\"";
//happen in background
LogUnzipper.StartInfo.CreateNoWindow = true;
LogUnzipper.StartInfo.UseShellExecute = false;
LogUnzipper.StartInfo.Arguments = action;
LogUnzipper.Start();
while (!LogUnzipper.HasExited)
{
LogUnzipper.WaitForExit(500);// 1/2 sec
}
//adding break point at this line yields no unzipped Log file :(
}
...
私の考えでは、どういうわけかcmdを間違って呼び出しているのstring action
ですか? Windowsコマンドプロンプトでテストしても、正しいフォーマットです。
*** ZipInfo.FullName は、例: "C:\Users\16208\Software\Beta\logs\6_2013\Log_10AM_to_11AM.zip" に沿ったものであることに注意してください。そのため、正確なパスを指定しています。圧縮されたアイテム。