Click here to Skip to main content
15,880,427 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Team

I have used the sharziplib.dll to unzip aroung 1400 folders which contains text files.
However after processing around 236 folders I land up with an error called "End of stream".
My Code:
C#
static void unzip()
        {
            try
            {
               
                var files = new List<string>(Directory.GetFiles(path, "*.zip*", SearchOption.AllDirectories));
                foreach (var item in files)
                {
 
                    var zipFileName = item;
                    var targetDir = Path.Combine(path,"unpack");
                    FastZip fastZip = new FastZip();
                    string fileFilter = null;
                    fastZip.ExtractZip(item, targetDir, fileFilter);
                    
                }

                Dictionary<string, int> Messagetype = new Dictionary<string, int>();
                var txtfiles = new List<string>(Directory.GetFiles(Path.Combine(path,"unpack"), "*.*", SearchOption.AllDirectories));
                foreach (var eachtxtfiles in txtfiles)
                {
                    //Reading the Text from the file
                    using (var reader = new StreamReader(eachtxtfiles))
                    {
                        string line;
                        int counter = 0;
                        line = reader.ReadLine();
                        while (line != null)
                        {
                            if (!string.IsNullOrEmpty(line))
                            {
                                //split the line
                                string[] parts = line.Split(new[] { "|" }, StringSplitOptions.None);

                                //get valid text
                                if (!Messagetype.ContainsKey(parts[1]))
                                    Messagetype[parts[1]] = 0;
                                Messagetype[parts[1]]++;
                            }
                            line = reader.ReadLine();


                        }

                    }
                    // Console.WriteLine(Messagetype.Count);



                }

                foreach (var ms in Messagetype.Keys)
                {
                    Console.WriteLine(ms + "-" + Messagetype[ms]);
                }
    


            }



            catch (Exception ex)
            {

                Console.WriteLine(ex.Message);
            }
            Console.ReadKey();

        }


What I have tried:

I made sure the folders are not corrupt ..
Contains only zip folders..
Same functions in my local system I just have 5 zipped folders. However in server we have about 1400+ zipped folders which is about 850GB data. In server I am running it as console application
Posted
Comments
Bernhard Hiller 2-Aug-16 2:49am    
where does that exception happen? In "fastZip.ExtractZip(item, targetDir, fileFilter);" or somewhere else? The code after that line is not zip-related.
ShaHam11 2-Aug-16 3:18am    
Yes it happens on that palace. However I cannot debug I have copied the console.exe file to server (entire debug folder). Your right the code after that is not related to unziping I am actually reading the contents from unzipped files...

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