Quantcast
Channel: SharpDevelop Community
Viewing all articles
Browse latest Browse all 1764

problem extracting with windows explorer

$
0
0

 hi

i am using the

ICSharpCode.SharpZipLib.dll for zipping a folder...when we are extarcting the zip file created by that dll using winzip,7zip,rar it is working properly..but when ia m extracting with windows explorer,subfolders are nt extarcting,only files are extracting....my code is given below..

using

System;

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

using

System.Collections.Generic;

using

 

System.Text;

using

 

System.IO;

using

 

System.IO.Compression;

using

 

ICSharpCode.SharpZipLib.Zip;

namespace

 

winzip_test3

 

class

Program

{

 

 

staticvoid Main(string

[ args)

 

ZipOutputStream zip = newZipOutputStream(File.Create(@"D:\abc\test.zip"

));

 

string folder = @"D:\abc\samples"

;

 

publicstaticvoid ZipFolder(string RootFolder, string CurrentFolder, ZipOutputStream

zStream)

 

string[ SubFolders = System.IO.Directory

.GetDirectories(CurrentFolder);

 

foreach (string Folder in

SubFolders)

 

string relativePath = CurrentFolder.Substring(RootFolder.Length) + "/"

;

 

if

(relativePath.Length > 1)

 

ZipEntry

dirEntry;

 

newZipEntry

(relativePath);

 

//dirEntry.DateTime = DateTime.Now;

}

 

 

foreach (string file in System.IO.Directory

.GetFiles(CurrentFolder))

 

privatestaticvoid AddFileToZip(ZipOutputStream zStream, string relativePath, string

file)

 

byte[ buffer = newbyte

[4096];

 

string fileRelativePath = (relativePath.Length > 1 ? relativePath : string.Empty) + Path

.GetFileName(file);

 

ZipEntry entry = newZipEntry

(fileRelativePath);

 

DateTime

.Now;

 

using (FileStream fs = File

.OpenRead(file))

 

int

sourceBytes;

 

do

{

sourceBytes = fs.Read(buffer, 0, buffer.Length);

zStream.Write(buffer, 0, sourceBytes);

}

 

while (sourceBytes > 0);

plz provide some solution as far as possible

thanks


Viewing all articles
Browse latest Browse all 1764