调用winrar压缩问题 ,压缩老有上层目录
调用winrar压缩问题 ,压缩老有上层目录
调用这个会压缩 Compress(string targetFileFullName, string destFolderPath)
如果targetFileFullName为c:\abc\yasuo目录
destFolderPath为d:\abc\backup 目录
调用后压缩则在d:\abc下生成backup.rar文件 且rar打开后会是abc目录,双击才是yasuo目录
现在想压缩成d:\abc\backup\yasuo.rar,且rar文件打开后是yasuo目录. 求救怎么修改
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.IO;
namespace Geoway.HJDMS.Service.Util
{
public class Decompression
{
private string _winrarPath;
private int _exitNum;
public Decompression(string winrarPath)
{
_winrarPath = winrarPath;
}
private void KillWinRar()
{
Process[] processes = Process.GetProcesses();
foreach (Process process in processes)
{
if (process.ProcessName == "WinRAR")
{
process.Kill();
}
}
}
public bool Compress(string targetFileFullName, string destFolderPath)
{
bool Result = false;
try
{
string cmd = string.Format( "A {0} {1} -r ", destFolderPath,targetFileFullName );
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = _winrarPath;
startInfo.Arguments = cmd;
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.WorkingDirectory = Path.GetDirectoryName(targetFileFullName);
Process process = new Process();
process.StartInfo = startInfo;