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;
}
}
}