Table of Contents

Class AllExtensionsHelper

Namespace
SunamoFileExtensions
Assembly
SunamoFileExtensions.dll

Helper class for working with file extensions and their types

public class AllExtensionsHelper
Inheritance
AllExtensionsHelper
Inherited Members
Extension Methods

Properties

ExtensionsByType

Dictionary of extensions grouped by type (with dot)

public static Dictionary<TypeOfExtension, List<string>>? ExtensionsByType { get; set; }

Property Value

Dictionary<TypeOfExtension, List<string>>

ExtensionsByTypeWithoutDot

Dictionary of extensions grouped by type (without dot)

public static Dictionary<TypeOfExtension, List<string>>? ExtensionsByTypeWithoutDot { get; set; }

Property Value

Dictionary<TypeOfExtension, List<string>>

Methods

AllExtensionsInFolderByCategory(List<string>, GetExtensionArgsFileExtensions?)

Gets all extensions in the specified files grouped by category

public static Dictionary<TypeOfExtension, List<string>> AllExtensionsInFolderByCategory(List<string> files, GetExtensionArgsFileExtensions? args = null)

Parameters

files List<string>

List of file paths

args GetExtensionArgsFileExtensions

Optional arguments for extension extraction

Returns

Dictionary<TypeOfExtension, List<string>>

Dictionary of extensions grouped by type

FindTypeWithDot(string)

Finds the type of extension for the specified extension with dot Returns TypeOfExtension.other if not found

public static TypeOfExtension FindTypeWithDot(string extension)

Parameters

extension string

The extension with dot

Returns

TypeOfExtension

The type of the extension

FindTypeWithoutDot(string)

Finds the type of extension for the specified extension without dot Returns TypeOfExtension.other if not found

public static TypeOfExtension FindTypeWithoutDot(string extension)

Parameters

extension string

The extension without dot

Returns

TypeOfExtension

The type of the extension

Initialize()

Initializes the extension dictionaries by reading all extension constants

public static void Initialize()

Initialize(bool)

Initializes the extension dictionaries

public static void Initialize(bool isCallingAllExtensionsHelperWithoutDotInitialize)

Parameters

isCallingAllExtensionsHelperWithoutDotInitialize bool

If true, also initializes AllExtensionsHelperWithoutDot

IsBinaryOrText(TypeOfExtension)

Determines whether the specified extension type is binary or text Returns true if binary, false if text Throws exception if TypeOfExtension.other is passed

public static bool IsBinaryOrText(TypeOfExtension typeOfExtension)

Parameters

typeOfExtension TypeOfExtension

The type of extension to check

Returns

bool

True if binary, false if text

Exceptions

Exception

Thrown when TypeOfExtension.other is passed

IsContained(string)

Checks if the specified extension is contained in the known extensions Extension can be with or without dot

public static bool IsContained(string extension)

Parameters

extension string

The extension to check

Returns

bool

True if the extension is known, false otherwise

IsFileHasKnownExtension(string)

Checks if the specified file has a known extension

public static bool IsFileHasKnownExtension(string filePath)

Parameters

filePath string

The file path to check

Returns

bool

True if the file has a known extension, false otherwise

NormalizeExtension2(string)

Normalizes the extension by converting to lowercase and trimming the dot

public static string NormalizeExtension2(string item)

Parameters

item string

The extension to normalize

Returns

string

The normalized extension