/// <summary> /// Append directory level information into the specified DataTable. /// </summary> /// <param name="qualifier">Top level directory.</param> /// <param name="dirs">Work in progress collection of directories.</param> /// <param name="estimate">Number of directory entries found. Used for future estimating.</param> public void DirLevel(string qualifier, string directory, ref List <string> dirs, ref long estimate) { string spec; string path; string name; path = directory; if (directory.Length > qualifier.Length) { directory = directory.Substring(qualifier.Length); } else { directory = string.Empty; } try { DirectoryInfo directoryInfo = new DirectoryInfo(path); directoryInfo.Refresh(); if (DirectoryExclusionsHelper.AllowDirectory(path)) { DirectoryInfo[] directoryInfoArray = directoryInfo.GetDirectories(); for (int row = 0; row < directoryInfoArray.Length; row++) { try { name = directoryInfoArray[row].Name; spec = path + Path.DirectorySeparatorChar.ToString() + name; if (DirectoryExclusionsHelper.AllowDirectory(spec)) { if (directoryInfoArray[row].Exists) { dirs.Add(spec); DirectoryEntry entry = new DirectoryEntry(); entry.StdHlq = qualifier.Trim(); entry.StdDir = directory.Trim(); entry.StdFile = name.Trim(); entry.StdSize = 0; entry.StdDate = System.DateTime.Parse("01/01/2000"); entry.StdType = "dir"; entry.CtlComparison = string.Empty; directoryListing.Add(entry); estimate += entry.StdSize; SignalUpdateProgress("DirList"); } } } catch (OleDbException oExceptionA) { System.Diagnostics.Debug.WriteLine(oExceptionA.Errors[0].Message); } if (action == "Cancel") { break; } } FileInfo[] fileInfoArray = directoryInfo.GetFiles(); for (int row = 0; row < fileInfoArray.Length; row++) { try { name = fileInfoArray[row].Name; spec = path + Path.DirectorySeparatorChar.ToString() + name; if (fileInfoArray[row].Exists) { string ext = Path.GetExtension(spec); if (ext.StartsWith(".")) { if (ext.Length > 1) { ext = ext.Substring(1); } else { ext = string.Empty; } } if (MonitoredTypesHelper.AllowFile(spec, true)) { DirectoryEntry entry = new DirectoryEntry(); entry.StdHlq = qualifier.Trim(); entry.StdDir = directory.Trim(); entry.StdFile = name.Trim(); entry.StdSize = fileInfoArray[row].Length; entry.StdDate = fileInfoArray[row].LastWriteTime; entry.StdType = ext; entry.CtlComparison = string.Empty; directoryListing.Add(entry); estimate += entry.StdSize; SignalUpdateProgress("DirList"); } } } catch (OleDbException exceptionB) { System.Diagnostics.Debug.WriteLine(exceptionB.Errors[0].Message); } if (action == "Cancel") { break; } } } } catch (DirectoryNotFoundException oExceptionNF) { System.Diagnostics.Debug.WriteLine(oExceptionNF.Message); } finally { } }
/// <summary> /// Append directory level information into the specified DataTable. /// </summary> /// <param name="qualifier">Top level directory.</param> /// <param name="dirs">Work in progress collection of directories.</param> /// <param name="estimate">Number of directory entries found. Used for future estimating.</param> public void DirLevel(string qualifier, string directory, ref List <string> dirs, ref long estimate) { string spec; string path; string name; path = directory; if (directory.Length > qualifier.Length) { directory = directory.Substring(qualifier.Length); } else { directory = string.Empty; } try { DirectoryInfo directoryInfo = new DirectoryInfo(path); directoryInfo.Refresh(); if (DirectoryExclusionsHelper.AllowDirectory(path)) { DirectoryInfo[] directoryInfoArray = directoryInfo.GetDirectories(); for (int row = 0; row < directoryInfoArray.Length; row++) { try { name = directoryInfoArray[row].Name; spec = path + Path.DirectorySeparatorChar.ToString() + name; if (DirectoryExclusionsHelper.AllowDirectory(spec)) { if (directoryInfoArray[row].Exists) { dirs.Add(spec); AdvancedDirectoryEntry entry = new AdvancedDirectoryEntry(); entry.StdHlq = qualifier.Trim(); entry.StdDir = directory.Trim(); entry.StdFile = name.Trim(); entry.StdSize = 0; entry.StdDate = System.DateTime.Parse("01/01/2000"); entry.SourceDate = entry.StdDate; entry.TargetDate = entry.StdDate; entry.SourceFile = entry.StdFile; entry.TargetFile = entry.StdFile; entry.StdType = "dir"; string matchAfter = string.Empty; entry.FolderGroup = GetFolderGroup(spec, ref matchAfter); string matchSpec = GetMatchPart(spec, matchAfter); entry.FolderGroupMatchPath = matchSpec; entry.FolderGroupMatchStem = matchSpec; entry.FolderGroupMatchFileSpec = matchSpec; entry.FolderGroupFullPath = spec; entry.FolderGroupFullStem = spec; entry.FolderGroupFullFileSpec = spec; entry.CtlComparison = string.Empty; directoryListing.Add(entry); estimate += entry.StdSize; SignalUpdateProgress("DirList", entry.StdSize); } } } catch (OleDbException oExceptionA) { System.Diagnostics.Debug.WriteLine(oExceptionA.Errors[0].Message); } if (Interrupt.Reason == "Cancel") { break; } } FileInfo[] fileInfoArray = directoryInfo.GetFiles(); for (int row = 0; row < fileInfoArray.Length; row++) { try { name = fileInfoArray[row].Name; spec = path + Path.DirectorySeparatorChar.ToString() + name; if (fileInfoArray[row].Exists) { string fullExt = Path.GetExtension(spec); string ext = fullExt; if (ext.StartsWith(".")) { if (ext.Length > 1) { ext = ext.Substring(1); } else { ext = string.Empty; } } if (MonitoredTypesHelper.AllowFile(spec, monitoredTypesOnly)) { AdvancedDirectoryEntry entry = new AdvancedDirectoryEntry(); entry.StdHlq = qualifier.Trim(); entry.StdDir = directory.Trim(); entry.StdFile = name.Trim(); entry.StdSize = fileInfoArray[row].Length; entry.StdDate = fileInfoArray[row].LastWriteTime; entry.SourceDate = entry.StdDate; entry.TargetDate = entry.StdDate; entry.SourceFile = entry.StdFile; entry.TargetFile = entry.StdFile; entry.StdType = ext; string matchAfter = string.Empty; entry.FolderGroup = GetFolderGroup(spec, ref matchAfter); entry.FolderGroupMatchPath = GetMatchPart(fileInfoArray[row].DirectoryName, matchAfter); string matchSpec = GetMatchPart(spec, matchAfter); string matchStem = RemoveExt(matchSpec, fullExt); entry.FolderGroupMatchStem = matchStem; entry.FolderGroupMatchFileSpec = matchSpec; entry.FolderGroupFullPath = fileInfoArray[row].DirectoryName; entry.FolderGroupFullStem = RemoveExt(spec, fullExt); entry.FolderGroupFullFileSpec = spec; entry.CtlComparison = string.Empty; directoryListing.Add(entry); estimate += entry.StdSize; SignalUpdateProgress("DirList", entry.StdSize); } } } catch (OleDbException exceptionB) { System.Diagnostics.Debug.WriteLine(exceptionB.Errors[0].Message); } if (Interrupt.Reason == "Cancel") { break; } } } } catch (DirectoryNotFoundException oExceptionNF) { System.Diagnostics.Debug.WriteLine(oExceptionNF.Message); } finally { } }