#### [DiGi\.Core\.IO](DiGi.Core.IO.Overview.md 'DiGi\.Core\.IO\.Overview') ## DiGi\.Core\.IO Namespace ### Classes ## Create Class ```csharp public static class Create ``` Inheritance [System\.Object](https://learn.microsoft.com/en-us/dotnet/api/system.object 'System\.Object') → Create ### Methods ## Create\.Archive\\(this byte\[\]\) Method Creates an archive from the specified byte array\. ```csharp public static DiGi.Core.IO.Classes.Archive? Archive(this byte[] bytes) where TSerializableObject : DiGi.Core.Interfaces.ISerializableObject; ``` #### Type parameters `TSerializableObject` The type of the serializable object contained within the archive\. #### Parameters `bytes` [System\.Byte](https://learn.microsoft.com/en-us/dotnet/api/system.byte 'System\.Byte')[\[\]](https://learn.microsoft.com/en-us/dotnet/api/system.array 'System\.Array') The byte array to create the archive from\. #### Returns [DiGi\.Core\.IO\.Classes\.Archive<](DiGi.Core.IO.Classes.md#DiGi.Core.IO.Classes.Archive_TSerializableObject_ 'DiGi\.Core\.IO\.Classes\.Archive\')[TSerializableObject](DiGi.Core.IO.md#DiGi.Core.IO.Create.Archive_TSerializableObject_(thisbyte[]).TSerializableObject 'DiGi\.Core\.IO\.Create\.Archive\\(this byte\[\]\)\.TSerializableObject')[>](DiGi.Core.IO.Classes.md#DiGi.Core.IO.Classes.Archive_TSerializableObject_ 'DiGi\.Core\.IO\.Classes\.Archive\') An [Archive<TSerializableObject>](DiGi.Core.IO.Classes.md#DiGi.Core.IO.Classes.Archive_TSerializableObject_ 'DiGi\.Core\.IO\.Classes\.Archive\') instance if successful; otherwise, `null`\. ## Create\.Archive\\(this byte\[\], TSerializableObject\) Method Creates an archive from the specified byte array and extracts the associated serializable object\. ```csharp public static DiGi.Core.IO.Interfaces.IArchive? Archive(this byte[] bytes, out TSerializableObject? serializableObject) where TSerializableObject : DiGi.Core.Interfaces.ISerializableObject; ``` #### Type parameters `TSerializableObject` The type of the serializable object to extract\. #### Parameters `bytes` [System\.Byte](https://learn.microsoft.com/en-us/dotnet/api/system.byte 'System\.Byte')[\[\]](https://learn.microsoft.com/en-us/dotnet/api/system.array 'System\.Array') The byte array to create the archive from\. `serializableObject` [TSerializableObject](DiGi.Core.IO.md#DiGi.Core.IO.Create.Archive_TSerializableObject_(thisbyte[],TSerializableObject).TSerializableObject 'DiGi\.Core\.IO\.Create\.Archive\\(this byte\[\], TSerializableObject\)\.TSerializableObject') When this method returns, contains the extracted serializable object, or null if extraction failed\. #### Returns [DiGi\.Core\.IO\.Interfaces\.IArchive](https://learn.microsoft.com/en-us/dotnet/api/digi.core.io.interfaces.iarchive 'DiGi\.Core\.IO\.Interfaces\.IArchive') An [DiGi\.Core\.IO\.Interfaces\.IArchive](https://learn.microsoft.com/en-us/dotnet/api/digi.core.io.interfaces.iarchive 'DiGi\.Core\.IO\.Interfaces\.IArchive') instance if successful; otherwise, `null`\. ## Create\.FileFilter\(string, string\[\]\) Method Creates a file filter with the specified name and allowed extensions\. ```csharp public static DiGi.Core.IO.Classes.FileFilter FileFilter(string name, params string[] extensions); ``` #### Parameters `name` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') The descriptive name of the filter\. `extensions` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String')[\[\]](https://learn.microsoft.com/en-us/dotnet/api/system.array 'System\.Array') An array of allowed file extensions\. #### Returns [FileFilter](DiGi.Core.IO.Classes.md#DiGi.Core.IO.Classes.FileFilter 'DiGi\.Core\.IO\.Classes\.FileFilter') A FileFilter configured with the specified name and extensions\. ## Create\.FileFilter\_AllFiles\(\) Method Creates a file filter that includes all files\. ```csharp public static DiGi.Core.IO.Classes.FileFilter FileFilter_AllFiles(); ``` #### Returns [FileFilter](DiGi.Core.IO.Classes.md#DiGi.Core.IO.Classes.FileFilter 'DiGi\.Core\.IO\.Classes\.FileFilter') A FileFilter that matches all files\. ## Modify Class ```csharp public static class Modify ``` Inheritance [System\.Object](https://learn.microsoft.com/en-us/dotnet/api/system.object 'System\.Object') → Modify ### Methods ## Modify\.UpdateLine\(string, int, string\) Method Updates a specific line in the file at the given path\. ```csharp public static bool UpdateLine(string? path, int index, string? line); ``` #### Parameters `path` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') The path to the file\. `index` [System\.Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32 'System\.Int32') The zero\-based index of the line to update\. `line` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') The new content for the line\. #### Returns [System\.Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean 'System\.Boolean') True if the update was successful; otherwise, false\. ## Modify\.UpdateLines\(string, Dictionary\\) Method Updates multiple lines in the file at the given path based on the provided dictionary of indices and content\. ```csharp public static System.Collections.Generic.HashSet? UpdateLines(string? path, System.Collections.Generic.Dictionary? lineDictionary); ``` #### Parameters `path` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') The path to the file to be updated\. `lineDictionary` [System\.Collections\.Generic\.Dictionary<](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.dictionary-2 'System\.Collections\.Generic\.Dictionary\`2')[System\.Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32 'System\.Int32')[,](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.dictionary-2 'System\.Collections\.Generic\.Dictionary\`2')[System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String')[>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.dictionary-2 'System\.Collections\.Generic\.Dictionary\`2') A dictionary where keys are line indices and values are the new content for those lines\. #### Returns [System\.Collections\.Generic\.HashSet<](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.hashset-1 'System\.Collections\.Generic\.HashSet\`1')[System\.Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32 'System\.Int32')[>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.hashset-1 'System\.Collections\.Generic\.HashSet\`1') A [System\.Collections\.Generic\.HashSet<>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.hashset-1 'System\.Collections\.Generic\.HashSet\`1') containing the indices of the lines that were successfully updated, or null if an error occurred\. ## Query Class ```csharp public static class Query ``` Inheritance [System\.Object](https://learn.microsoft.com/en-us/dotnet/api/system.object 'System\.Object') → Query ### Methods ## Query\.AbsolutePath\(this string, string\) Method Combines a directory path and a relative path to create an absolute path\. ```csharp public static string? AbsolutePath(this string? directory, string? relativePath); ``` #### Parameters `directory` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') The base directory path\. `relativePath` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') The relative path to combine with the directory\. #### Returns [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') The resulting absolute path string\. ## Query\.Deserialize\\(this IArchive\) Method Deserializes a USerializableObject from the specified archive\. ```csharp public static USerializableObject? Deserialize(this DiGi.Core.IO.Interfaces.IArchive archive) where USerializableObject : DiGi.Core.Interfaces.ISerializableObject; ``` #### Type parameters `USerializableObject` The type of object to deserialize\. #### Parameters `archive` [DiGi\.Core\.IO\.Interfaces\.IArchive](https://learn.microsoft.com/en-us/dotnet/api/digi.core.io.interfaces.iarchive 'DiGi\.Core\.IO\.Interfaces\.IArchive') The archive to deserialize from\. #### Returns [USerializableObject](DiGi.Core.IO.md#DiGi.Core.IO.Query.Deserialize_USerializableObject_(thisDiGi.Core.IO.Interfaces.IArchive).USerializableObject 'DiGi\.Core\.IO\.Query\.Deserialize\\(this DiGi\.Core\.IO\.Interfaces\.IArchive\)\.USerializableObject') The deserialized USerializableObject, or null if deserialization fails\. ## Query\.Filter\(FileFilter\[\]\) Method Joins multiple file filters into a pipe\-separated string\. ```csharp public static string? Filter(params DiGi.Core.IO.Classes.FileFilter[]? fileFilters); ``` #### Parameters `fileFilters` [FileFilter](DiGi.Core.IO.Classes.md#DiGi.Core.IO.Classes.FileFilter 'DiGi\.Core\.IO\.Classes\.FileFilter')[\[\]](https://learn.microsoft.com/en-us/dotnet/api/system.array 'System\.Array') The array of file filters to be joined\. #### Returns [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') A pipe\-separated string containing the combined filters, or null if no filters are provided\. ## Query\.IsPathFullyQualified\(string\) Method Checks if a path is fully qualified \(absolute\)\. ```csharp public static bool IsPathFullyQualified(string? path); ``` #### Parameters `path` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') The path to check\. #### Returns [System\.Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean 'System\.Boolean') True if the path is fully qualified; otherwise, false\. ## Query\.Lines\(string, int\) Method Reads a specified number of lines from a file\. ```csharp public static System.Collections.Generic.List? Lines(string? path, int count); ``` #### Parameters `path` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') The path to the file to read\. `count` [System\.Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32 'System\.Int32') The number of lines to read from the file\. #### Returns [System\.Collections\.Generic\.List<](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1 'System\.Collections\.Generic\.List\`1')[System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String')[>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1 'System\.Collections\.Generic\.List\`1') A list of strings containing the lines read, or null if the operation fails\. ## Query\.Locked\(this FileInfo\) Method Checks if a file is locked by another process\. ```csharp public static bool Locked(this System.IO.FileInfo? fileInfo); ``` #### Parameters `fileInfo` [System\.IO\.FileInfo](https://learn.microsoft.com/en-us/dotnet/api/system.io.fileinfo 'System\.IO\.FileInfo') The file information of the file to check\. #### Returns [System\.Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean 'System\.Boolean') True if the file is locked; otherwise, false\. ## Query\.RelativePath\(string, string\) Method Calculates the relative path from one directory to another\. ```csharp public static string? RelativePath(string? relativeTo, string? path); ``` #### Parameters `relativeTo` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') The base directory to calculate the relative path from\. `path` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') The target path to make relative\. #### Returns [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') The calculated relative path, or null if it cannot be determined\. ## Query\.Serialize\(this ISerializableObject\) Method Serializes an ISerializableObject into an IArchive\. ```csharp public static DiGi.Core.IO.Interfaces.IArchive? Serialize(this DiGi.Core.Interfaces.ISerializableObject serializableObject); ``` #### Parameters `serializableObject` [DiGi\.Core\.Interfaces\.ISerializableObject](https://learn.microsoft.com/en-us/dotnet/api/digi.core.interfaces.iserializableobject 'DiGi\.Core\.Interfaces\.ISerializableObject') The object to be serialized\. #### Returns [DiGi\.Core\.IO\.Interfaces\.IArchive](https://learn.microsoft.com/en-us/dotnet/api/digi.core.io.interfaces.iarchive 'DiGi\.Core\.IO\.Interfaces\.IArchive') An [DiGi\.Core\.IO\.Interfaces\.IArchive](https://learn.microsoft.com/en-us/dotnet/api/digi.core.io.interfaces.iarchive 'DiGi\.Core\.IO\.Interfaces\.IArchive') containing the serialized data, or `null` if serialization fails\.