Class FileIndex
- Namespace
- SunamoFilesIndex
- Assembly
- SunamoFilesIndex.dll
Resembles database work - uses int numbers to mark folders
Working with CheckBoxData Use FolderItem, FileItem
public class FileIndex
- Inheritance
-
FileIndex
- Inherited Members
- Extension Methods
Fields
Files
All files in the index
public List<FileItem> Files
Field Value
Properties
BasePath
Gets the base path of the indexed folder structure
public string? BasePath { get; }
Property Value
Methods
AddFolderRecursively(string)
Process all files including subfolders Folder path must end with backslash
public void AddFolderRecursively(string folder)
Parameters
folderstringFolder path to index (must end with backslash)
AggregateFilesFromAllFolders(string, FileIndex, Dictionary<string, int>, List<string>)
Add file to dictionary with relative path if it doesn't exist Use relative path to file to find relative directory ID and insert with file path ID to dictionary
public static void AggregateFilesFromAllFolders(string folderOfSolution, FileIndex fileIndex, Dictionary<string, int> relativeFilePathForEveryColumn, List<string> filesFromAllFoldersUniqueRelative)
Parameters
folderOfSolutionstringBase path that will be discarded, used to make relative file paths
fileIndexFileIndexFileIndex object containing files to process
relativeFilePathForEveryColumnDictionary<string, int>Dictionary where key is relative file path, value is column index
filesFromAllFoldersUniqueRelativeList<string>List of relative file paths, used to fill dictionary, not modified
CheckVertically(CheckBoxDataShared<TWithSize<string>>[,])
Check (or uncheck) all in columns by filesize
public static CheckBoxDataShared<TWithSize<string>>[,] CheckVertically(CheckBoxDataShared<TWithSize<string>>[,] allRows)
Parameters
allRowsCheckBoxDataShared<TWithSize<string>>[,]The matrix of checkbox data to process
Returns
- CheckBoxDataShared<TWithSize<string>>[,]
Updated matrix with ticked/unticked checkboxes based on file sizes
ExistsFilesOnDrive(Dictionary<string, FileIndex>, Dictionary<string, int>)
Create matrix from files where each file will be in specific column When file doesn't exist, it will be null Load size of files from disc
public static CheckBoxDataShared<TWithSize<string>?>?[,] ExistsFilesOnDrive(Dictionary<string, FileIndex> files, Dictionary<string, int> relativeFilePathForEveryColumn)
Parameters
filesDictionary<string, FileIndex>Dictionary with folder paths as keys and FileIndex objects as values
relativeFilePathForEveryColumnDictionary<string, int>Dictionary where key is relative file path, value is column index
Returns
- CheckBoxDataShared<TWithSize<string>>[,]
Matrix of CheckBoxData with file information
FindAllFilesWithName(string)
Find all files with the specified name
public List<FileItem> FindAllFilesWithName(string name)
Parameters
namestringName of the file to find
Returns
GetFilesInRelativeFolder(int)
Get all files in relative folder by index
public IList<FileItem> GetFilesInRelativeFolder(int relativeDirectoryIndex)
Parameters
relativeDirectoryIndexintIndex of the relative directory
Returns
GetFoldersWithName(int[], string)
Get folders with specified name from given parent IDs
public IList<FolderItem> GetFoldersWithName(int[] parentIds, string name)
Parameters
parentIdsint[]Array of parent folder IDs to search in (null = search all)
namestringName of the folder to find
Returns
- IList<FolderItem>
List of folders matching the criteria
GetIndexOfFolder(FolderItem)
Get index of folder in internal collection
public int GetIndexOfFolder(FolderItem item)
Parameters
itemFolderItemFolder item to find
Returns
- int
Index of the folder
GetRelativeFolder(int)
Get relative folder path by index
public string GetRelativeFolder(int folder)
Parameters
folderintIndex of the folder
Returns
- string
Relative folder path
GetRelativeFolder(string)
Return index of folder or -1 if not found
public int GetRelativeFolder(string folder)
Parameters
folderstringFolder path to search for
Returns
- int
Index of the folder or -1 if not found
IndexFolders(IList<string>)
Process recursively all folders - for every folder one FileIndex object in output
public static Dictionary<string, FileIndex> IndexFolders(IList<string> folders)
Parameters
Returns
- Dictionary<string, FileIndex>
Dictionary with folder paths as keys and FileIndex objects as values
Nuke()
Clear folders and files collection
public void Nuke()