public static void ProcessFile(Delimon.Win32.IO.FileInfo fInfo)
{
string extention = Path.GetExtension(fInfo.FullName);
if (extention == null)
extention = "";
if (IsArchive(extention))
{
//extract code
SevenZipExtractor extractor = null;
try
{
//path to the systems temporary folder
String tempFolderPath = Path.GetTempPath();
tempFolderPath += "temp_dir\\";
//create a directory to dump everything into inside the temp folder
Directory.CreateDirectory(tempFolderPath);
//set the path of the 7z.dll (it needs to be in the debug folder)
SevenZipExtractor.SetLibraryPath("7z.dll");
extractor = new SevenZipExtractor(fInfo.FullName);
//Extract the entire file
extractor.ExtractArchive(tempFolderPath);
extractor.Dispose();
bool arcs = true;
while (arcs)
{
arcs = false;
// traverse files
string[] fileEntries = Directory.GetFiles(tempFolderPath, "*.*", SearchOption.AllDirectories);
foreach (string fileName in fileEntries)
{
//Console.WriteLine("IN ARCHIVE: " + fileName);
FileInfo archive = new FileInfo(fileName);
if (IsArchive(archive.Extension.ToString()))
{
arcs = true;
extractor = new SevenZipExtractor(fileName);
extractor.ExtractArchive(tempFolderPath);
File.Delete(fileName);
}
}
}
int[][] totals = {new int[5], new int[9]}; //totals[0] count; totals[1] results;
string[] fileEntries2 = Directory.GetFiles(tempFolderPath, "*.*", SearchOption.AllDirectories);
foreach (string fileName in fileEntries2)
{
int[][] results = ProcessNonArchive(new Delimon.Win32.IO.FileInfo(fileName), true);
if (MainForm.socialSecurityMode)
{
totals[0][0] += results[0][0];
if (results[0][1] > totals[0][1])
totals[0][1] = results[0][1];
}
if (MainForm.creditCardMode)
{
totals[1][0] += results[1][0];
if (results[1][1] > totals[1][1])
totals[1][1] = results[1][1];
}
}
//Count how many files in archive
//int count = Directory.GetFiles(tempFolderPath, "*.*", SearchOption.AllDirectories).Length;
//delete the temporary directory we created at the beginning
Directory.Delete(tempFolderPath, true);
if (totals[0][1] > 0)
{
//WriteToLogFile("Detected: " + fInfo.FullName + " Priority: " + (ScanData.Code)totals[1]);
if (MainForm.socialSecurityMode)
{
ScanData returnedData = new ScanData(totals[0][0], totals[0][1], totals[0][3], totals[0][4]);
Database.AddToTableScanned(fInfo.Name, fInfo.FullName, returnedData);
try { mainUIForm.lblItemsFound.BeginInvoke(new MainForm.InvokeDelegateFound(mainUIForm.UpdateLblItemsFound), new object[] { numFound++ }); }
catch (InvalidOperationException) { }
}
if (MainForm.creditCardMode)
{
CreditData ccReturnedData = new CreditData(totals[1][0], totals[1][1], totals[1][3], totals[1][4], totals[1][5], totals[1][6], totals[1][7], totals[1][8]);
Database.AddToTableCreditCard(fInfo.Name, fInfo.FullName, ccReturnedData);
try { mainUIForm.lblItemsFound.BeginInvoke(new MainForm.InvokeDelegateFound(mainUIForm.UpdateLblItemsFound), new object[] { numFound++ }); }
catch (InvalidOperationException) { }
}
}
}
catch (Exception e)
{
//get rid of the object because it is unmanaged
extractor.Dispose();
Console.WriteLine(e.Message);
}
}
else
{
int[][] ignore = ProcessNonArchive(fInfo, false);
}
}