private void GetAllDirRec(ShellObject path) { AllDirsCount = 0; ShellContainer con = (ShellContainer)ShellContainer.FromParsingName(path.ParsingName); foreach (ShellObject item in con) { try { if (item.IsFolder) { try { AllDirsCount++; GetFilesRec(item); } catch (Exception) { } } } catch (Exception) { } } con.Dispose(); }
private void GetFilesRec(ShellObject path) { ShellContainer con = (ShellContainer)ShellContainer.FromParsingName(path.ParsingName); foreach (ShellObject item in con) { try { if (item.IsFolder) { try { GetFilesRec(item); } catch (Exception) { } } else { shol.Add(item); } } catch (Exception) { } } con.Dispose(); }
/// <summary> /// This method creates a shell object from a file path. This shell object will /// allow the retrieval of property values. /// </summary> private static ShellObject createShellObject(string filePath) { try { return(ShellContainer.FromParsingName(filePath)); } catch (ShellException) { Console.WriteLine("Unable to create a ShellObject from this input. Please enter a path to an existing file or directory."); restartProgram = true; } return(null); }