2013-02-18 3 views
1

현재 하나의 단일 zip 파일로 압축해야하는 여러 경로를 정의해야하는 작은 프로젝트를 진행하고 있습니다.코드에서 SevenZipSharp로 파일 제외

이제 다음과 같은 경우가 있습니다. 이러한 경로 중 하나는 디렉토리이며, 재귀 적으로 압축해야합니다 (포함 된 모든 파일과 하위 폴더 포함). 압축하기 전에 권한을 포함하여 몇 가지 사항을 확인합니다. 압축하려는 현재 사용자가 파일이나 폴더에 대한 권한이없는 경우 제외해야합니다.

이제 여러 파일과 디렉토리를 재귀 모드에서 압축을 제외시킬 수 있습니까?

나는 이미 이와 같은 것을 시도했지만 arguement는 cmd에만있는 것처럼 보입니다.

compressor.CustomParameters.Add("-x", "@C:\\Users\\******\\Desktop\\exclude.txt"); 

답변

1

SevenZipSharp에서 파일을 제외 할 가능성을 찾지 못했습니다. 대신 지금 파일을 제거하는 좋은 방법이 DotNetZip 사용 ZipFile.RemoveEntry()ZipFile.RemoveEntries() 예컨대 : 나는 SevenZipSharp이 파일을 제외 할 수 있음을 발견

foreach (string removePath in Verifier.ExcludePaths) 
{ 
    try 
    { 
     // Remove files and directories to be excluded 
     zipFile.RemoveEntry(removePath); 
    } 
    catch (Exception) 
    { 
     Logger.Warn("Could not exclude path \"{0}\".",removePath); 
    } 
} 
0

:

SevenZipCompressor sevenZipCompressor = new SevenZipCompressor(); 
sevenZipCompressor.ModifyArchive(archiveName, dictionary); 
// string archiveName: archive name 
// Dictionary<int Index, string NewFileName>: NewFileName or Null value to delete the corresponding index.