24GB的tar.gz DECOM preSS使用sharpziplib [英] 24GB tar.gz Decompress using sharpziplib

查看:107
本文介绍了24GB的tar.gz DECOM preSS使用sharpziplib的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个当前进程中提取tar.gz,而当前进程不能处理超过4GB ......我想知道我在做什么错误导致我开始使用sharpzip一个错误的lib它说,参数长度可以不能小于零....所有的注释code是当前进程

请参阅下面的code,给我方向

 公共静态无效ExtractTarGZFiles(字符串strExtractionPath,串strInboundFolder)
    {
        名单<字符串>文件=新的名单,其中,串>();
        字符串strFile = Path.GetFullPath(ConfigurationManager.AppSettings [InboundFolderPath]的ToString());
        如果(mblnRunForFile)
        {
            System.IO.FileInfo ioInfo =新的FileInfo(mstrFilename);
            strFile = ioInfo.DirectoryName;
            files.Add(ioInfo.Name);

        }
        其他
        {
            文件= System.IO.Directory.GetFiles(ConfigurationManager.AppSettings [InboundFolderPath],*。广州)了ToList()。
        }

        的foreach(在文件中字符串的文件)
        {
            尝试
            {
            //字符串stFilePath =文件;
            //字符串testingthisdamnthing = strInboundFolder + mstrFilename;
            //的FileStream XStream的=新的FileStream(stFilePath,FileMode.Open,FileAccess.Read,FileShare.None);
            //xstream.Close();
            //字符串strTemp = ConfigurationManager.AppSettings [ExtractTempFolderPath];
            // TarArchive objTA = TarArchive.CreateInputTarArchive(新GZipStream(新的FileStream(stFilePath,FileMode.Open,FileAccess.Read),COM pressionMode.Decom preSS));
            //objTA.ProgressMessageEvent + = ExtractTarNotifier;
             //objTA.ExtractContents(strTemp);



            // DirectoryInfo的dirtemp =新的DirectoryInfo(strTemp);
            DirectoryInfo的dirExtract =新的DirectoryInfo(strExtractionPath);

            流inStream = File.OpenRead(stFilePath);
            流gzipStream =新GZipInputStream(inStream中);

            TarArchive tarArchive = TarArchive.CreateInputTarArchive(gzipStream);
            tarArchive.ExtractContents(ConfigurationManager.AppSettings [ExtractFolderPath]);
            tarArchive.Close();

            gzipStream.Close();
            inStream.Close();
            //而(IsFileExistsinTempPath(dirtemp,dirExtract))
            // {
            //    //没做什么
            //}
            // CopyFilesFromTempToExtract(dirtemp,dirExtract);
            //objTA.Close();
            //Logger.Write(tar.gz的文件DECOM pressed成功);
            MonthLog.Log(tar.gz的文件DECOM pressed成功,月,3,2,System.Diagnostics.TraceEventType.Information,mstrFilename);
            System.IO.File.Copy(stFilePath,ConfigurationManager.AppSettings [ArchiveFolderPath] +新的FileInfo(stFilePath).name和真正的);
            File.Delete(stFilePath);
            //Logger.Write(移动到归档文件夹的tar.gz文件);
            MonthlyGreenPackageLog.Log(移动到归档文件夹的tar.gz文件,月,3,2,System.Diagnostics.TraceEventType.Information,mstrFilename);

            }
                赶上(System.IO.IOException前)
                {
                    //去下一个文件
                    //Logger.Write("Unable打开COM pressed文件);
                    MonthLog.Log(无法打开COM pressed文件,月,1,1,System.Diagnostics.TraceEventType.Error,mstrFilename);
                    电子邮件objEmail1 =新的电子邮件();
                    objEmail1.IsBodyHTML = TRUE;
                    objEmail1.FromAddress = ConfigurationManager.AppSettings [FromAddress];
                    字符串[] strToAddresses = ConfigurationManager.AppSettings [ExceptionAddress]斯普利特('')。
                    objEmail1.SetToAddress(strToAddresses);
                    objEmail1.Subject =本月文件+ mstrFilename +无法DECOM preSS;
                    objEmail1.Body =异常+ ex.Message +出现,而DECOM pressing文件;
                    //objEmail.AddAttachment("Exception发生而processingfiles);
                    objEmail1.SendEmail();
                    //Logger.Write("Sent邮件到所有的地址);
                    抛出前;
                }
                赶上(例外前)
                {
                    //Logger.Write("Exception+ ex.Message +出现,而DECOM pressing文件);
                    MonthlyGreenPackageLog.Log(异常+ ex.Message +出现,而DECOM pressing文件,Monthl,1,1,System.Diagnostics.TraceEventType.Error,mstrFilename);
                    电子邮件objEmail =新的电子邮件();
                    objEmail.IsBodyHTML = TRUE;
                    objEmail.FromAddress = ConfigurationManager.AppSettings [FromAddress];
                    字符串[] strToAddresses = ConfigurationManager.AppSettings [ExceptionAddress]斯普利特('')。
                    objEmail.SetToAddress(strToAddresses);
                    objEmail.Subject =tar.gz的月文件+ mstrFilename +无法DECOM preSS;
                    objEmail.Body =异常+ ex.Message +出现,而DECOM pressing文件;
                    //objEmail.AddAttachment("Exception发生在处理ADX文件);
                    objEmail.SendEmail();
                    //Logger.Write("Sent邮件到所有的地址);
                    抛出前;
                }

            }
        }
 

解决方案

我对你的三个潜在的解决方案,但我不能告诉你是否有任何人会实际工作。

  1. 使用解压缩从流的例子通过内存流,所以你永远不需要(为什么现在失败是)来加载整个事情。
  2. 切换到使用 DotNetZip ,这可能对处理在x86机器上的大文件更多的选择
  3. 找到一个正规unzipper应用程序,它可以编写脚本,或者可以监控目录,并解压缩,然后才会慢慢给你的应用程序。

I have a current process to extract tar.gz but the current process can not handle over 4gb... I was wondering what I am doing wrong to cause me to get a error using the sharpzip lib It says that parameter length can not be less that Zero.... All of the commented out code is the current process

Please see the below code and give me direction

public static void ExtractTarGZFiles(string strExtractionPath, string strInboundFolder)
    {
        List<string> files = new List<string>();
        string strFile = Path.GetFullPath(ConfigurationManager.AppSettings["InboundFolderPath"].ToString());
        if (mblnRunForFile)
        {
            System.IO.FileInfo ioInfo = new FileInfo(mstrFilename);
            strFile = ioInfo.DirectoryName;
            files.Add(ioInfo.Name);

        }
        else
        {
            files = System.IO.Directory.GetFiles(ConfigurationManager.AppSettings["InboundFolderPath"], "*.gz").ToList();
        }

        foreach (string file in files)
        {
            try
            {
            //string stFilePath = file;
            //string testingthisdamnthing = strInboundFolder + mstrFilename;
            //FileStream xstream = new FileStream(stFilePath, FileMode.Open, FileAccess.Read, FileShare.None);
            //xstream.Close();
            //string strTemp = ConfigurationManager.AppSettings["ExtractTempFolderPath"];
            //TarArchive objTA = TarArchive.CreateInputTarArchive(new GZipStream(new FileStream(stFilePath, FileMode.Open, FileAccess.Read), CompressionMode.Decompress));
            //objTA.ProgressMessageEvent += ExtractTarNotifier;
             //objTA.ExtractContents(strTemp);



            //DirectoryInfo dirtemp = new DirectoryInfo(strTemp);
            DirectoryInfo dirExtract = new DirectoryInfo(strExtractionPath);

            Stream inStream = File.OpenRead(stFilePath);
            Stream gzipStream = new GZipInputStream(inStream);

            TarArchive tarArchive = TarArchive.CreateInputTarArchive(gzipStream);
            tarArchive.ExtractContents(ConfigurationManager.AppSettings["ExtractFolderPath"]);
            tarArchive.Close();

            gzipStream.Close();
            inStream.Close();
            //while (IsFileExistsinTempPath(dirtemp, dirExtract))
            //{
            //    //Do nothing
            //}
            //CopyFilesFromTempToExtract(dirtemp, dirExtract);
            //objTA.Close();
            //Logger.Write(" Tar.Gz files Decompressed Successfully");
            MonthLog.Log("Tar.Gz files Decompressed Successfully", "Month", 3, 2, System.Diagnostics.TraceEventType.Information, mstrFilename);
            System.IO.File.Copy(stFilePath, ConfigurationManager.AppSettings["ArchiveFolderPath"] + new FileInfo(stFilePath).Name, true);
            File.Delete(stFilePath);
            //Logger.Write(" Tar.GZ files Moved to Archive Folder");
            MonthlyGreenPackageLog.Log("Tar.Gz files Moved to Archive Folder", "Month", 3, 2, System.Diagnostics.TraceEventType.Information, mstrFilename);

            }
                catch (System.IO.IOException ex)
                {
                    //go to next file
                    //Logger.Write("Unable to open compressed file");
                    MonthLog.Log("Unable to open compressed file", "Month", 1, 1, System.Diagnostics.TraceEventType.Error, mstrFilename);
                    Email objEmail1 = new Email();
                    objEmail1.IsBodyHTML = true;
                    objEmail1.FromAddress = ConfigurationManager.AppSettings["FromAddress"];
                    string[] strToAddresses = ConfigurationManager.AppSettings["ExceptionAddress"].Split(',');
                    objEmail1.SetToAddress(strToAddresses);
                    objEmail1.Subject = "The Month  File  " + mstrFilename + " Failed to Decompress ";
                    objEmail1.Body = " Exception " + ex.Message + " occured while decompressing file";
                    //objEmail.AddAttachment("Exception occured while processingfiles");
                    objEmail1.SendEmail();
                    //Logger.Write("Sent a mail to all the Address");
                    throw ex;
                }
                catch (Exception ex)
                {
                    //Logger.Write("Exception " + ex.Message + " occured while decompressing file");
                    MonthlyGreenPackageLog.Log("Exception " + ex.Message + " occured while decompressing file", "Monthl", 1, 1, System.Diagnostics.TraceEventType.Error, mstrFilename);
                    Email objEmail = new Email();
                    objEmail.IsBodyHTML = true;
                    objEmail.FromAddress = ConfigurationManager.AppSettings["FromAddress"];
                    string[] strToAddresses = ConfigurationManager.AppSettings["ExceptionAddress"].Split(',');
                    objEmail.SetToAddress(strToAddresses);
                    objEmail.Subject = "The tar.gz Month File  " + mstrFilename + " Failed to Decompress ";
                    objEmail.Body = " Exception " + ex.Message + " occured while decompressing file";
                    //objEmail.AddAttachment("Exception occured while processing ADX files");
                    objEmail.SendEmail();
                    //Logger.Write("Sent a mail to all the Address");
                    throw ex;
                }

            }
        }

解决方案

I have three potential solutions for you, but I can't tell you whether any of them will actually work.

  1. Use the Unzip from Stream example to stream it through memory so you never need to load the whole thing (which is why it fails now).
  2. Switch to using DotNetZip, which might have more options for handling large files on an x86 machine.
  3. Find a regular unzipper application which can be scripted or that can monitor a directory, and unzip it before it gets to your application.

这篇关于24GB的tar.gz DECOM preSS使用sharpziplib的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆