2012-05-23 2 views
1

폴더 안에있는 파일 및 폴더를 선택하려고합니다.하지만 선택한 폴더까지 모든 폴더를 선택하는 것 같습니다. 최종 폴더의 파일은 있지만 폴더는 압축하지 않습니다. 예를 들어 tbFolder에서 "C : \ Users \ tomb \ Desktop \ DeOld \ Mota7"이라는 문자열이 있습니다.이 폴더를 선택하고이 폴더, 이미지 및 전체의 전체 내용을 압축합니다. 그러나 무슨 일이 일어나고은 다음과 같다 :VB.net 폴더에있는 파일 및 폴더 선택

enter image description here

그 폴더에 폴더 구조까지를 만들어 내가는 압축이 아닌 폴더 측면에서 바로 파일을 추가합니다. 여기

System.IO.Directory.GetFiles(DirectoryToZip) 

전체 코드입니다 : 내가 선 조정할 필요가 추측하고있어

Private Sub btnCreate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCreate.Click 

     Dim ZipFile As String = "C:\Releases\" & drpService.Text & "-" & DateTime.Now.ToString("YYmmDD") & ".zip" 
     Dim DirectoryToZip As String = tbFolder.Text 
     Dim filenames As String() = System.IO.Directory.GetFiles(DirectoryToZip) 

     Using zip As ZipFile = New ZipFile 
      zip.AddFiles(filenames) 
      zip.Save(ZipFile) 
     End Using 


    End Sub 
+0

위치 타 우편 번호 라이브러리를 사용하고 있습니까? – Maciej

답변

1

당신이 DotNetZip를 사용하는 경우, 전체 디렉토리를 추가하는 자신의 사이트에 대한 예제가를

zip.AddDirectory(DirectoryToZip, "RootFolderInZip");