public Folder(AxShockwaveFlashObjects.AxShockwaveFlash flash, ListOfFiles <FileStructure> filesList, string[] includingExtenstion, string[] excludingExtenstion ) { Flash = new FlashPropertise(flash); InludingExtensionList = includingExtenstion; ExcludingExtensionList = excludingExtenstion; FilesList = filesList; }
public void SearchAndAdd(ListOfFiles <FileStructure> fileList, bool getContents, string[] InludingExtensionList, string[] ExcludingExtensionList, DateTime startDate, DateTime endDate, int dateType = -1, int FileSizeType = -1, long fileSizeStart = -1, long fileSizeEnd = -1, bool lookForDate = false, AxShockwaveFlashObjects.AxShockwaveFlash flx = null) { //if (fileList == null || fileList.Count == 0) { // return; //} if (FileSizeType == FileSizeTypeStructure.KB) { fileSizeStart = fileSizeStart * (int)FileSizeTypeStructure.KB_1; fileSizeEnd = fileSizeEnd * (int)FileSizeTypeStructure.KB_1; } else if (FileSizeType == FileSizeTypeStructure.MB) { fileSizeStart = fileSizeStart * (int)FileSizeTypeStructure.MB_1; fileSizeEnd = fileSizeEnd * (int)FileSizeTypeStructure.MB_1; } else if (FileSizeType == FileSizeTypeStructure.GB) { fileSizeStart = fileSizeStart * (int)FileSizeTypeStructure.GB_1; fileSizeEnd = fileSizeEnd * (int)FileSizeTypeStructure.GB_1; } else { fileSizeStart = -1; fileSizeEnd = -1; } foreach (var filestr in fileList) { //new Thread(() => { var isExtensionExist = false; if (InludingExtensionList != null) { isExtensionExist = InludingExtensionList.Any(n => n == filestr.Extension); } var isDisableExtensionExist = false; if (ExcludingExtensionList != null) { isDisableExtensionExist = ExcludingExtensionList.Any(n => n == filestr.Extension); } bool addFile = false; bool isExtensionRight = false; bool isSizeRight = false; bool isDateRight = false; if (isExtensionExist && !isDisableExtensionExist) { isExtensionRight = true; } if (filestr.FileName == "Biology_2_2_2.txt") { string swe = filestr.FileName; } if (FileSizeType != FileSizeTypeStructure.NoLimit) { if (filestr.SizeBytes >= fileSizeStart && filestr.SizeBytes <= fileSizeEnd) { isSizeRight = true; //only if size meets the condition then add the file. } } else { isSizeRight = true; //no size limit } if (lookForDate) { if (dateType == DateTypeStructure.Modified_Date) { DateTime dt = filestr.ModifiedDate.Date; if (dt != null && (dt >= startDate.Date && dt <= endDate.Date)) { isDateRight = true; } } else if (dateType == DateTypeStructure.Created_Date) { DateTime dt = filestr.CreatedDate.Date; if (dt != null && (dt >= startDate.Date && dt <= endDate.Date)) { isDateRight = true; } } else if (dateType == DateTypeStructure.Access_Date) { DateTime dt = filestr.LastAccessDate.Date; if (dt != null && (dt >= startDate.Date && dt <= endDate.Date)) { isDateRight = true; } } } else { isDateRight = true; } if (isSizeRight && isDateRight && isExtensionRight) { addFile = true; } if (addFile) { new Thread(() => { if (folder.IsMatchInText(filestr.FileName, fileList)) { FlashPropertise.addListItemStatic(filestr.FileName, filestr.ExactLocation, flx); } else if (getContents && !filestr.IsContentEmpty && folder.IsMatchInText(filestr.Content, fileList)) { FlashPropertise.addListItemStatic(filestr.FileName, filestr.ExactLocation, flx); } else if (getContents && filestr.SizeBytes <= FileSizeTypeStructure.MB_1 * 3) { filestr.Content = folder.ReadFile(filestr.ExactLocation, filestr.SizeBytes); if (filestr.IsContentEmpty) { } fileList.IsSavingNecessary = true; } }).Start(); } //}).Start(); } }