Click here to Skip to main content
15,884,353 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi guyes,
how to read the files list which is in zip format of single file in c# code
Posted
Updated 16-Jun-20 2:01am
Comments
AmitGajjar 17-Jul-13 1:33am    
have you tried google ?

Hi, you want to read zip file only by using C# classes instead of third party source,
Please refer to this links:

http://msdn.microsoft.com/en-us/library/system.io.compression.gzipstream(VS.80).aspx[^]
http://msdn.microsoft.com/en-US/library/system.io.compression.deflatestream(VS.80).aspx[^]


You could use SharpZipLib or DotNetZip [^] to unzip the file and read the files.

http://www.icsharpcode.net/OpenSource/SharpZipLib/Default.aspx[^]
 
Share this answer
 
v2
Try this :
C#
using ICSharpCode.SharpZipLib.Zip;
using ICSharpCode.SharpZipLib.Core;

public class UnZipFileFolder
    {
        public string setPassword = "";

        public void UnZip(string srcFileName, string dstFolderName)
        {
            using (ZipInputStream s = new ZipInputStream(File.OpenRead(@"" + srcFileName)))
            {
                if (setPassword.Trim() != "") s.Password = setPassword;
                ZipEntry theEntry;
                while ((theEntry = s.GetNextEntry()) != null)
                {
                    string directoryName = Path.GetDirectoryName(dstFolderName);
                    string fileName = dstFolderName + "\\" + Path.GetFileName(theEntry.Name);

                    if (fileName != String.Empty)
                    {
                        using (FileStream streamWriter = File.Create(fileName))
                        {
                            int size = 2048;
                            byte[] data = new byte[2048];
                            while (true)
                            {
                                size = s.Read(data, 0, data.Length);
                                if (size > 0)
                                {
                                    streamWriter.Write(data, 0, size);
                                }
                                else
                                {
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
}
 
Share this answer
 
Comments
ALTT 17-Jul-13 3:44am    
very Thanks
Dineshshp 18-Jul-13 3:12am    
Please Vote Me If Your Problem Has Been Solved...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900