Table of Contents

Class FS

Namespace
SunamoFileSystem
Assembly
SunamoFileSystem.dll

File System utility class providing file and directory operations

public class FS
Inheritance
FS
Inherited Members
Extension Methods

Fields

DEndsWithReplaceInFile

Default file name pattern for ends-with replacement operations.

public const string DEndsWithReplaceInFile = "SubdomainHelperSimple.cs"

Field Value

string

DeleteFileMaybeLocked

Action delegate to delete a file that may be locked by another process.

public static Action<string>? DeleteFileMaybeLocked

Field Value

Action<string>

FileUtilWhoIsLocking

Function to determine which processes are locking a file.

public static Func<string, bool, List<Process>>? FileUtilWhoIsLocking

Field Value

Func<string, bool, List<Process>>

FilesWhichSurelyExists

List of files that are confirmed to exist on disk.

public static List<string> FilesWhichSurelyExists

Field Value

List<string>

InvalidFileNameChars

List of all invalid file name characters including extended Unicode.

public static List<char> InvalidFileNameChars

Field Value

List<char>

InvalidFileNameCharsString

Field as string because array requires ToArray() every time to construct string

public static string InvalidFileNameCharsString

Field Value

string

ReplaceIncorrectFor

Replacement string for incorrect file name characters.

public static string ReplaceIncorrectFor

Field Value

string

invalidCharsForMapPath

List of invalid characters for path mapping operations.

protected static List<char> invalidCharsForMapPath

Field Value

List<char>

invalidFileNameCharsReadonly

Read-only list of invalid file name characters from the OS.

protected static readonly List<char> invalidFileNameCharsReadonly

Field Value

List<char>

invalidFileNameCharsWithoutDelimiterOfFolders

Invalid file name characters excluding directory separators.

protected static List<char> invalidFileNameCharsWithoutDelimiterOfFolders

Field Value

List<char>

invalidFileNameStringsReadonly

Read-only list of invalid file name characters as strings.

protected static readonly List<string> invalidFileNameStringsReadonly

Field Value

List<string>

invalidPathChars

List of invalid path characters including directory separators.

protected static List<char> invalidPathChars

Field Value

List<char>

Methods

AbsoluteFromCombinePath(string)

Usage: SunamoFubuCsprojFileHelper.GetProjectsInSlnFile Cant name GetAbsolutePath because The call is ambiguous between the following methods or properties: 'CAChangeContent.ChangeContent0(null,List<string>, Func<string, string, string>)' and 'CAChangeContent.ChangeContent0(null,List<string>, Func<string, string>)'

public static string AbsoluteFromCombinePath(string path)

Parameters

path string

Path to convert to absolute path

Returns

string

AddExtensionIfDontHave(string, string)

Adds a file extension if the path does not already have one.

public static string AddExtensionIfDontHave(string file, string ext)

Parameters

file string

The file parameter.

ext string

The ext parameter.

Returns

string

AddUpfoldersToRelativePath(int, string, char)

Prepends parent directory references to a relative path.

public static string AddUpfoldersToRelativePath(int i2, string file, char delimiter)

Parameters

i2 int

The i2 parameter.

file string

The file parameter.

delimiter char

The delimiter parameter.

Returns

string

AllExtensionsInFolders(List<string>, GetExtensionArgs?)

files as .bowerrc return whole

public static List<string> AllExtensionsInFolders(List<string> filesFull, GetExtensionArgs? args = null)

Parameters

filesFull List<string>

List of full file paths.

args GetExtensionArgs

Arguments controlling the operation behavior.

Returns

List<string>

AllExtensionsInFolders(SearchOption, params string[])

Gets all unique file extensions found in the specified folders.

public static List<string> AllExtensionsInFolders(SearchOption so, params string[] folders)

Parameters

so SearchOption

The so parameter.

folders string[]

The folders parameter.

Returns

List<string>

AllIncludeIfOnlyLetters(string)

Wraps a search term with wildcards if it contains only letters.

public static string AllIncludeIfOnlyLetters(string extension)

Parameters

extension string

The extension parameter.

Returns

string

BasePath(List<string>, string)

Finds which base path contains the specified path.

public static string? BasePath(List<string> basePaths, string path)

Parameters

basePaths List<string>

The basePaths parameter.

path string

The file or directory path.

Returns

string

ChangeDirectory(string, string)

Pokud hledáš metodu ReplacePathToFile, je to tato. Sloučeny protože dělali totéž.

public static string ChangeDirectory(string fileName, string changeFolderTo)

Parameters

fileName string
changeFolderTo string

Returns

string

ChangeExtension(string, string, bool)

A2 is path of target file

public static string ChangeExtension(string filePath, string newExt, bool physically)

Parameters

filePath string
newExt string
physically bool

Returns

string

ChangeFilename(string, string, bool)

Changes the file name of a path, optionally renaming the physical file.

public static string ChangeFilename(string filePath, string newFileNameWithoutPath, bool physically)

Parameters

filePath string

The file path.

newFileNameWithoutPath string

The newFileNameWithoutPath parameter.

physically bool

The physically parameter.

Returns

string

Combine(params string[])

Cant return with end slash becuase is working also with files Use this than Path.Combine which if argument starts with backslash ignore all arguments before this

public static string Combine(params string[] parts)

Parameters

parts string[]

The path parts to combine.

Returns

string

CombineDir(params string[])

Combines multiple path segments into a directory path.

public static string CombineDir(params string[] parts)

Parameters

parts string[]

The parts parameter.

Returns

string

CombineFile(params string[])

Combines multiple path segments into a file path.

public static string CombineFile(params string[] parts)

Parameters

parts string[]

The parts parameter.

Returns

string

CombineWithoutFirstCharUpper(params string[])

Cant return with end slash becuase is working also with files

public static string CombineWithoutFirstCharUpper(params string[] text)

Parameters

text string[]

The text to process.

Returns

string

CompareTWithInt<T>(TWithInt<T>, TWithInt<T>)

Compares two TWithInt instances by their count in descending order.

public static int CompareTWithInt<T>(TWithInt<T> first, TWithInt<T> second)

Parameters

first TWithInt<T>

The first parameter.

second TWithInt<T>

The second parameter.

Returns

int

Type Parameters

T

ContainsInvalidFileNameChars(string)

Checks if a string contains invalid file name characters.

public static bool ContainsInvalidFileNameChars(string arg)

Parameters

arg string

The arg parameter.

Returns

bool

ContainsInvalidPathCharForPartOfMapPath(string)

Checks if a path segment contains invalid characters for mapping.

public static bool ContainsInvalidPathCharForPartOfMapPath(string path)

Parameters

path string

The file or directory path.

Returns

bool

CopyAllFiles(ILogger, string, string, FileMoveCollisionOption, string?)

A4 contains can use ! for negation

public static void CopyAllFiles(ILogger logger, string path, string to, FileMoveCollisionOption collisionOption, string? contains = null)

Parameters

logger ILogger

Logger instance for diagnostic messages.

path string

The file or directory path.

to string
collisionOption FileMoveCollisionOption
contains string

CopyAllFilesRecursively(ILogger, string, string, FileMoveCollisionOption, string?)

Copies all files recursively from source to target directory.

public static void CopyAllFilesRecursively(ILogger logger, string path, string to, FileMoveCollisionOption collisionOption, string? contains = null)

Parameters

logger ILogger

Logger instance for diagnostic messages.

path string

The source directory path.

to string

The target directory path.

collisionOption FileMoveCollisionOption

How to handle file name collisions.

contains string

Optional filter string; only files containing this text are copied. Prefix with '!' for negation.

CopyAs0KbFiles(string, string)

Copies files as empty 0KB files to the target directory.

public static void CopyAs0KbFiles(string pathDownload, string pathVideos0Kb)

Parameters

pathDownload string

The pathDownload parameter.

pathVideos0Kb string

The pathVideos0Kb parameter.

CopyAs0KbFilesSubfolders(string, string)

Copies the folder structure as empty 0KB files including subfolders.

public static void CopyAs0KbFilesSubfolders(string pathDownload, string pathVideos0Kb)

Parameters

pathDownload string
pathVideos0Kb string

CopyFile(ILogger, string, string, FileMoveCollisionOption, bool)

Copies a file from source to destination.

public static void CopyFile(ILogger logger, string sourceFilePath, string fileTo2, FileMoveCollisionOption collisionOption, bool terminateProcessIfIsInUsed = false)

Parameters

logger ILogger

Logger instance for diagnostic messages.

sourceFilePath string

The source file path to copy from.

fileTo2 string

The destination file path to copy to.

collisionOption FileMoveCollisionOption

How to handle file name collisions.

terminateProcessIfIsInUsed bool

Whether to terminate the process that is locking the file.

CopyFile(ILogger, string, string, bool)

Copy file by ordinal way tady byly 2 metody CopyFile(string, string, bool) jedna text A3 terminateProcessIfIsInUsed, druhá text overwrite Ta druhá jen volala A3 text FileMoveCollisionOption.Overwrite

public static void CopyFile(ILogger logger, string jsFiles, string value, bool terminateProcessIfIsInUsed = false)

Parameters

logger ILogger

Logger instance for diagnostic messages.

jsFiles string
value string

The value to process.

terminateProcessIfIsInUsed bool

Whether to terminate the process if the file is in use.

CopyFile(string, string, FileMoveCollisionOption)

Copies a file from source to destination.

public static void CopyFile(string sourceFilePath, string fileTo2, FileMoveCollisionOption collisionOption)

Parameters

sourceFilePath string

The sourceFilePath parameter.

fileTo2 string

The fileTo2 parameter.

collisionOption FileMoveCollisionOption

How to handle collisions.

CopyFilesOfExtensions(string, string, params string[])

Copies files with specified extensions from source to target directory.

public static void CopyFilesOfExtensions(string folderFrom, string folderTo, params string[] extensions)

Parameters

folderFrom string

The folderFrom parameter.

folderTo string

The folderTo parameter.

extensions string[]

The extensions parameter.

CopyFolder(string, string)

Use CopyAllFilesRecursively instead

public static void CopyFolder(string sourceDir, string targetDir)

Parameters

sourceDir string
targetDir string

CopyMoveFilePrepare(ref string, ref string, FileMoveCollisionOption)

Prepares source and target paths for a copy or move operation with collision handling.

public static bool CopyMoveFilePrepare(ref string sourceFilePath, ref string fileTo, FileMoveCollisionOption collisionOption)

Parameters

sourceFilePath string

The sourceFilePath parameter.

fileTo string

The fileTo parameter.

collisionOption FileMoveCollisionOption

How to handle collisions.

Returns

bool

CopyMoveFilesInList(ILogger, List<string>, string, string, List<string>, bool, bool, Dictionary<string, List<string>>, bool)

Všechny soubory které se podaří přesunout vymažu z A1 A1 MUST BE WITH EXTENSION A4 can be null if !A5 In A1 will keep files which doesnt exists in A3 A4 is files from A1 which wasnt founded in A2 A7 is files

public static void CopyMoveFilesInList(ILogger logger, List<string> filesFrom, string folderFrom, string folderTo, List<string> wasntExistsInFrom, bool mustExistsInTarget, bool copy, Dictionary<string, List<string>> files, bool overwrite = true)

Parameters

logger ILogger

Logger instance for diagnostic messages.

filesFrom List<string>

List of source file paths relative to folderFrom.

folderFrom string

Source folder path.

folderTo string

Target folder path.

wasntExistsInFrom List<string>

List to collect files that did not exist in source.

mustExistsInTarget bool

Whether files must exist in target.

copy bool

Whether to copy (true) or move (false).

files Dictionary<string, List<string>>

Dictionary mapping file categories to their paths.

overwrite bool

Whether to overwrite existing files.

CopyMoveFilesInListSimple(ILogger, List<string>, string, string, bool, bool)

Simplified version of CopyMoveFilesInList for basic copy/move operations.

public static void CopyMoveFilesInListSimple(ILogger logger, List<string> files, string basePathCjHtml1, string basePathCjHtml2, bool copy, bool overwrite = true)

Parameters

logger ILogger

Logger instance for diagnostic messages.

files List<string>

The files parameter.

basePathCjHtml1 string

The basePathCjHtml1 parameter.

basePathCjHtml2 string

The basePathCjHtml2 parameter.

copy bool

The copy parameter.

overwrite bool

Whether to overwrite existing files.

CopyMoveFromMultiLocationIntoOne(ILogger, List<string>, string, string)

A1 must be with extensions!

public static void CopyMoveFromMultiLocationIntoOne(ILogger logger, List<string> files, string folderFrom, string folderTo)

Parameters

logger ILogger

Logger instance for diagnostic messages.

files List<string>
folderFrom string
folderTo string

CopyStream(Stream, Stream)

Copies data from one stream to another.

public static void CopyStream(Stream input, Stream output)

Parameters

input Stream

The input parameter.

output Stream

The output parameter.

CopyTo(string, string, FileMoveCollisionOption)

Copy file A1 into A2

public static void CopyTo(string value, string targetDirectory, FileMoveCollisionOption collisionOption)

Parameters

value string
targetDirectory string
collisionOption FileMoveCollisionOption

How to handle file name collisions.

CreateDirectory(string)

All occurences Path's method in sunamo replaced

public static void CreateDirectory(string value)

Parameters

value string

The value to process.

CreateDirectory(string, DirectoryCreateCollisionOption, SerieStyleFS, bool)

Creates a directory with collision handling options.

public static string CreateDirectory(string value, DirectoryCreateCollisionOption whenExists, SerieStyleFS serieStyle, bool reallyCreate)

Parameters

value string

The value to process.

whenExists DirectoryCreateCollisionOption

The whenExists parameter.

serieStyle SerieStyleFS

The serieStyle parameter.

reallyCreate bool

The reallyCreate parameter.

Returns

string

CreateDirectoryIfNotExists(string)

Creates a directory if it does not already exist.

public static void CreateDirectoryIfNotExists(string path)

Parameters

path string

The file or directory path.

CreateFileIfDoesntExists(string)

Creates an empty file if it does not already exist.

public static void CreateFileIfDoesntExists(string path)

Parameters

path string

The file or directory path.

CreateFileWithTemplateContent(string, string, string, string)

Creates a file with content based on a template with placeholder replacement.

public static void CreateFileWithTemplateContent(string folder, string files, string ext, string templateFromContent)

Parameters

folder string

The directory path.

files string

The files parameter.

ext string

The ext parameter.

templateFromContent string

The templateFromContent parameter.

CreateFoldersPsysicallyUnlessThere(string)

Creates all parent folders of the specified path if they don't exist

public static void CreateFoldersPsysicallyUnlessThere(string path)

Parameters

path string

The folder path to create

CreateInOtherLocationSameFolderStructure(string, string)

Recreates the folder structure from one location in another.

public static void CreateInOtherLocationSameFolderStructure(string from, string to)

Parameters

from string

The from parameter.

to string

The to parameter.

CreateNewFolderPathWithEndingNextTo(string, string)

Creates a new folder path adjacent to the specified path.

public static string CreateNewFolderPathWithEndingNextTo(string folder, string ending)

Parameters

folder string

The directory path.

ending string

The ending parameter.

Returns

string

CreateUpfoldersPsysicallyUnlessThere(string)

Creates all parent folders of the specified path if they don't exist

public static void CreateUpfoldersPsysicallyUnlessThere(string path)

Parameters

path string

The file or folder path

DeleteAllEmptyDirectories(string, params string[])

Zjistí všechny složky rekurzivně z A1 a prvně maže samozřejmě ty, které mají více tokenů

public static void DeleteAllEmptyDirectories(string value, params string[] excludePatterns)

Parameters

value string

The directory path to process

excludePatterns string[]

Paths containing these strings will not be deleted

DeleteAllRecursively(string, bool)

Deletes all files and optionally directories recursively.

public static void DeleteAllRecursively(string path, bool rootDirectoryToo = false)

Parameters

path string

The file or directory path to delete contents from.

rootDirectoryToo bool

Whether to also delete the root directory itself.

DeleteAllRecursivelyAndThenDirectory(string)

Vyhazuje výjimky, takže musíš volat value try-catch bloku

public static void DeleteAllRecursivelyAndThenDirectory(string path)

Parameters

path string

The directory path to delete

DeleteDuplicatedImages(List<string>)

Unit tests = OK

public static void DeleteDuplicatedImages(List<string> files)

Parameters

files List<string>

DeleteEmptyFiles(string, SearchOption)

Deletes all empty (0-byte) files in the specified folder.

public static Task DeleteEmptyFiles(string folder, SearchOption so)

Parameters

folder string

The directory path to search in.

so SearchOption

Specifies whether to search the current directory or all subdirectories.

Returns

Task

DeleteFile(string)

Deletes a file from disk, attempting to handle locked files.

public static void DeleteFile(string filePath)

Parameters

filePath string

The file path.

DeleteFileIfExists(string)

Odstraňuje samozřejmě ve výjimce

public static void DeleteFileIfExists(string path)

Parameters

path string

DeleteFilesWithSameContent(List<string>)

Working fine, verified by Unit tests

public static void DeleteFilesWithSameContent(List<string> files)

Parameters

files List<string>

DeleteFilesWithSameContentBytes(List<string>)

Unit tests = OK

public static void DeleteFilesWithSameContentBytes(List<string> files)

Parameters

files List<string>

DeleteFilesWithSameContentWorking<TContent, ColType>(List<string>, Func<string, TContent>)

Deletes files with same content by comparing their content using the provided read function Currently kept as sync because Func only has Invoke, cannot use async benefits

public static void DeleteFilesWithSameContentWorking<TContent, ColType>(List<string> files, Func<string, TContent> readFunc) where TContent : notnull

Parameters

files List<string>

List of file paths to check for duplicates

readFunc Func<string, TContent>

Function to read file content

Type Parameters

TContent

The type of content to compare

ColType

The collection element type

DeleteFoldersWhichNotContains(string, string, IList<string>)

Deletes folders that do not contain files matching specified patterns.

public static void DeleteFoldersWhichNotContains(string value, string folder, IList<string> excludedContainingTexts)

Parameters

value string

The value to process.

folder string

The directory path.

excludedContainingTexts IList<string>

The excludedContainingTexts parameter.

DeleteSerieDirectoryOrCreateNew(string)

Delete whole folder A1. If fail, only "1" subdir Use in RepairBlogContent but sample data is NA Deleting old folder hiearchy and create new

public static int DeleteSerieDirectoryOrCreateNew(string repairedBlogPostsFolder)

Parameters

repairedBlogPostsFolder string

Returns

int

DeleteWrongCharsInDirectoryName(string)

Removes invalid characters from a directory name.

public static string DeleteWrongCharsInDirectoryName(string path)

Parameters

path string

The file or directory path.

Returns

string

DeleteWrongCharsInFileName(string, bool)

Removes invalid characters from a file name.

public static string DeleteWrongCharsInFileName(string path, bool isPath)

Parameters

path string

The file or directory path.

isPath bool

The isPath parameter.

Returns

string

DetectPathDelimiter(string)

Detects the path delimiter used in a path string.

public static Tuple<bool, bool> DetectPathDelimiter(string path)

Parameters

path string

The file or directory path.

Returns

Tuple<bool, bool>

DetectPathDelimiterChar(string)

Detects the path delimiter character used in a path string.

public static char DetectPathDelimiterChar(string path)

Parameters

path string

The file or directory path.

Returns

char

DirectoriesWithToken(string, AscDesc)

Gets directories sorted by a numeric token in their path.

public static List<TWithInt<string>> DirectoriesWithToken(string value, AscDesc sortOrder)

Parameters

value string

The value to process.

sortOrder AscDesc

The sortOrder parameter.

Returns

List<TWithInt<string>>

DirectoryExistsAndIsNotEmpty(string)

Checks if a directory exists and contains files or subdirectories.

public static bool DirectoryExistsAndIsNotEmpty(string value)

Parameters

value string

The value to process.

Returns

bool

DirectoryListing(string, string, SearchOption)

Lists files in a directory matching a pattern.

public static List<string> DirectoryListing(string path, string mask, SearchOption so)

Parameters

path string

The file or directory path.

mask string

The mask parameter.

so SearchOption

The so parameter.

Returns

List<string>

ExistsDirectory(string)

Determines whether the specified directory exists on disk.

public static bool ExistsDirectory(string path)

Parameters

path string

The file or directory path.

Returns

bool

ExistsDirectory(string, bool)

Determines whether the specified directory exists on disk.

public static bool ExistsDirectory(string directoryPath, bool isFalseIfContainsNoFile = false)

Parameters

directoryPath string

The directory path to check.

isFalseIfContainsNoFile bool

Whether to return false if the directory exists but contains no files.

Returns

bool

ExistsDirectoryNull(string)

For empty or whitespace return false.

public static bool? ExistsDirectoryNull(string directoryPath)

Parameters

directoryPath string

Returns

bool?

ExistsDirectoryNull(string, bool)

Returns null if the directory does not exist.

public static bool? ExistsDirectoryNull(string directoryPath, bool isFalseIfContainsNoFile = false)

Parameters

directoryPath string

The directory path to check.

isFalseIfContainsNoFile bool

Whether to return false if the directory exists but contains no files.

Returns

bool?

ExistsDirectoryWorker(string, bool)

Convert to UNC path

public static bool ExistsDirectoryWorker(string directoryPath, bool isFalseIfContainsNoFile = false)

Parameters

directoryPath string

The directory path to check

isFalseIfContainsNoFile bool

Return false if directory contains no files

Returns

bool

ExistsFile(string)

Determines whether the specified file exists on disk.

public static bool ExistsFile(string path)

Parameters

path string

The file or directory path.

Returns

bool

ExistsFile(string, bool)

Dont check for size Into A2 is good put true - when storage was fulled, all new files will be written with zero size. But then failing because HtmlNode as null - empty string as input But when file is big, like backup of DB, its better false.. Then will be avoid reading whole file to determining their size and totally blocking HW resources on VPS A2 must be false otherwise read file twice Change falseIfSizeZeroOrEmpty = false. Its extremely resource intensive

public static Task<bool> ExistsFile(string selectedFile, bool falseIfSizeZeroOrEmpty)

Parameters

selectedFile string

The file path to check for existence.

falseIfSizeZeroOrEmpty bool

Whether to return false if the file exists but has zero size or is empty.

Returns

Task<bool>

ExpandEnvironmentVariables(EnvironmentVariables)

Expands a known environment variable to its value.

public static string ExpandEnvironmentVariables(EnvironmentVariables environmentVariable)

Parameters

environmentVariable EnvironmentVariables

The environmentVariable parameter.

Returns

string

FileToDirectory(ref string)

Converts a file path to its parent directory path.

public static void FileToDirectory(ref string dir)

Parameters

dir string

The dir parameter.

FilesWhichContainsAll(object, string, params string[])

Finds files matching a pattern that contain all required contents.

public static List<string> FilesWhichContainsAll(object sunamo, string searchPattern, params string[] requiredContents)

Parameters

sunamo object

The sunamo parameter.

searchPattern string

The searchPattern parameter.

requiredContents string[]

The requiredContents parameter.

Returns

List<string>

FilesWithSameName(string, string, SearchOption)

Usage: FileWasntFoundInDirectory Vrátí cestu a název souboru text ext

public static string FilesWithSameName(string folder, string searchPattern, SearchOption searchOption)

Parameters

folder string
searchPattern string
searchOption SearchOption

Returns

string

FilterInRootAndInSubFolder(string, List<string>)

Separates files into root-level and subfolder groups.

public static List<string> FilterInRootAndInSubFolder(string rootFolder, List<string> files)

Parameters

rootFolder string

The rootFolder parameter.

files List<string>

The files parameter.

Returns

List<string>

FirstCharUpper(string)

Converts the first character of a string to uppercase

public static string FirstCharUpper(string text)

Parameters

text string

The text to process

Returns

string

String with first character in uppercase

FirstCharUpper(string, bool)

Converts the first character of a path to uppercase.

public static string? FirstCharUpper(string text, bool only = false)

Parameters

text string

The text to process.

only bool

Whether to only uppercase the first character and lowercase the rest.

Returns

string

FirstCharUpper(ref string)

Converts the first character of a path to uppercase.

public static string FirstCharUpper(ref string result)

Parameters

result string

The result parameter.

Returns

string

FoldersWithSubfolder(string, string)

Finds all folders that contain a specific subfolder.

public static List<string> FoldersWithSubfolder(string solutionFolder, string folderName)

Parameters

solutionFolder string

The solutionFolder parameter.

folderName string

The folderName parameter.

Returns

List<string>

GetAbsolutePath(string, string)

Working - see unit tests if A1 not ending with , GetDirectoryName

public static string GetAbsolutePath(string dir, string relativePath)

Parameters

dir string
relativePath string

Returns

string

GetAbsolutePath2(string, string)

Not working - see unit tests

public static string GetAbsolutePath2(string relativePath, string dir)

Parameters

relativePath string
dir string

Returns

string

GetActualDateTime()

Returns the current date and time as a file-safe string.

public static string GetActualDateTime()

Returns

string

GetDictionaryByExtension(string, string, SearchOption)

Both filenames and extension convert to lowercase Filename is without extension

public static Dictionary<string, List<string>> GetDictionaryByExtension(string folder, string mask, SearchOption searchOption)

Parameters

folder string
mask string
searchOption SearchOption

Returns

Dictionary<string, List<string>>

GetDictionaryByFileNameWithExtension(List<string>)

In key are just filename, in value full path to all files

public static Dictionary<string, List<string>> GetDictionaryByFileNameWithExtension(List<string> files)

Parameters

files List<string>

List of file paths.

Returns

Dictionary<string, List<string>>

GetDirectoryName(string)

Usage: Exceptions.FileWasntFoundInDirectory

public static string GetDirectoryName(string path)

Parameters

path string

The file or directory path.

Returns

string

GetDirectoryNameIfIsFile(string)

Returns the directory name if the path points to a file, otherwise returns the path.

public static string GetDirectoryNameIfIsFile(string path)

Parameters

path string

The file or directory path.

Returns

string

GetExtension(string, GetExtensionArgs?)

.babelrc etc. return as is. but files which not contains only alphanumeric will be returned when A3 (and A2 is then ignored) ALL EXT. HAVE TO BE ALWAYS LOWER Return in lowercase

public static string GetExtension(string value, GetExtensionArgs? args = null)

Parameters

value string

The file path to extract extension from

args GetExtensionArgs

Optional arguments for extension extraction

Returns

string

GetFileInStartupPath(string)

Jen kvuli starým aplikacím, at furt nenahrazuji.

public static string GetFileInStartupPath(string value)

Parameters

value string

The value to process.

Returns

string

GetFileName(string)

Gets the file name from a full path.

public static string GetFileName(string filePath)

Parameters

filePath string

The file path.

Returns

string

GetFileNameWithoutExtension(string)

Gets the file name from a path without the extension.

public static string GetFileNameWithoutExtension(string text)

Parameters

text string

The text to process.

Returns

string

GetFileNameWithoutExtensionAndExtension(string, out string, out string)

A1 může obsahovat celou cestu, vrátí jen název sobuoru bez připony a příponu

public static void GetFileNameWithoutExtensionAndExtension(string filePath, out string file, out string ext)

Parameters

filePath string

The file path.

file string
ext string

GetFileNameWithoutExtensionLower(string)

Pokud by byla cesta zakončená backslashem, vrátila by metoda Path.GetFileName prázdný řetězec.

public static string GetFileNameWithoutExtensionLower(string text)

Parameters

text string

The file path to process

Returns

string

GetFileNameWithoutExtensionNoAc<StorageFile>(StorageFile)

Problémová metoda Píše že nemůže najít SunamoValues, přitom value nugetech je

public static StorageFile GetFileNameWithoutExtensionNoAc<StorageFile>(StorageFile text)

Parameters

text StorageFile

The text to process.

Returns

StorageFile

Type Parameters

StorageFile

GetFileNameWithoutExtensions(string)

Remove all extensions, not only one

public static string GetFileNameWithoutExtensions(string path)

Parameters

path string

File path to process

Returns

string

GetFileNameWithoutOneExtension(string)

Gets the file name by removing the last path segment.

public static string GetFileNameWithoutOneExtension(string path)

Parameters

path string

The file or directory path.

Returns

string

GetFileNamesWoExtension(List<string>)

Gets file names without extensions from a list of paths.

public static List<string> GetFileNamesWoExtension(List<string> jpgcka)

Parameters

jpgcka List<string>

The jpgcka parameter.

Returns

List<string>

GetFileSerie(string, SerieStyleFS)

Retun null if serie is not defined

public static string? GetFileSerie(string fnwoe, SerieStyleFS ss)

Parameters

fnwoe string
ss SerieStyleFS

Returns

string

GetFileSeries(string, string, string)

Get number higher by one from the number filenames with highest value (as 3.txt)

public static string GetFileSeries(string folder, string fileName, string ext)

Parameters

folder string
fileName string

The file name.

ext string

Returns

string

GetFileSize(string)

Gets the size of a file in bytes.

public static long GetFileSize(string filePath)

Parameters

filePath string

The file path.

Returns

long

GetFiles(string, bool)

Gets files from a directory, optionally including subdirectories.

public static List<string> GetFiles(string folderPath, bool recursive)

Parameters

folderPath string

The folderPath parameter.

recursive bool

The recursive parameter.

Returns

List<string>

GetFolderSize(DirectoryInfo)

Calculates the total size of all files in a folder.

public static long GetFolderSize(DirectoryInfo directoryInfo)

Parameters

directoryInfo DirectoryInfo

The directoryInfo parameter.

Returns

long

GetFolderSize(string)

Calculates the total size of all files in a folder.

public static long GetFolderSize(string path)

Parameters

path string

The file or directory path.

Returns

long

GetFullPath(string)

Gets the fully qualified path for a relative path.

public static string GetFullPath(string path)

Parameters

path string

The file or directory path.

Returns

string

GetNameWithoutSeries(string, bool)

Do A1 se dává buď celá cesta ke souboru, nebo jen jeho název(může být i včetně neomezeně přípon) A2 říká, zda se má vrátit plná cesta ke souboru A1, upraví se pouze samotný název souboru Works for brackets, not dash

public static string GetNameWithoutSeries(string path, bool a1IsWithPath)

Parameters

path string
a1IsWithPath bool

Returns

string

GetNameWithoutSeries(string, bool, out bool, SerieStyleFS)

Extracts the base name from a file name by removing series suffixes.

public static string GetNameWithoutSeries(string path, bool a1IsWithPath, out bool hasSerie, SerieStyleFS serieStyle)

Parameters

path string

The file or directory path.

a1IsWithPath bool

The a1IsWithPath parameter.

hasSerie bool

The hasSerie parameter.

serieStyle SerieStyleFS

The serieStyle parameter.

Returns

string

GetNameWithoutSeries(string, bool, out bool, SerieStyleFS, out int)

Vrací vždy text příponou Do A1 se dává buď celá cesta ke souboru, nebo jen jeho název(může být i včetně neomezeně přípon) A2 říká, zda se má vrátit plná cesta ke souboru A1, upraví se pouze samotný název souboru When file has unknown extension, return SE Default for A4 was bracket

public static string GetNameWithoutSeries(string path, bool a1IsWithPath, out bool hasSerie, SerieStyleFS serieStyle, out int serie)

Parameters

path string

The file path to extract the name from.

a1IsWithPath bool

Whether the path includes the directory path.

hasSerie bool

Output flag indicating whether a series suffix was found.

serieStyle SerieStyleFS

The serie naming style to use.

serie int

Output value of the series number found, or -1 if none.

Returns

string

GetNameWithoutSeriesNoOut(string, bool, SerieStyleFS)

1 = filename without serie 2 = has serie

public static (string, bool) GetNameWithoutSeriesNoOut(string path, bool a1IsWithPath, SerieStyleFS serieStyle)

Parameters

path string
a1IsWithPath bool

Whether the first argument includes a path.

serieStyle SerieStyleFS

Returns

(string, bool)

GetNormalizedExtension(string)

Gets the normalized extension from a file path.

public static string GetNormalizedExtension(string filename)

Parameters

filename string

The filename parameter.

Returns

string

GetPathAndFileName(string, out string, out string)

Usage: Exceptions.FileWasntFoundInDirectory

public static void GetPathAndFileName(string filePath, out string path, out string file)

Parameters

filePath string

The file path.

path string
file string

GetPathAndFileName(string, out string, out string, out string)

Vrátí cestu a název souboru text ext a ext

public static void GetPathAndFileName(string filePath, out string path, out string file, out string ext)

Parameters

filePath string

The file path.

path string
file string
ext string

GetPathAndFileNameWithoutExtension(string, out string, out string, out string)

Vrátí cestu a název souboru bez ext a ext All returned is normal case

public static void GetPathAndFileNameWithoutExtension(string filePath, out string path, out string file, out string ext)

Parameters

filePath string

The file path.

path string
file string
ext string

GetSizeIn(long, ComputerSizeUnits, ComputerSizeUnits)

Converts a file size value between different computer size units.

public static long GetSizeIn(long value, ComputerSizeUnits fromUnit, ComputerSizeUnits to)

Parameters

value long

The value to process.

fromUnit ComputerSizeUnits

The fromUnit parameter.

to ComputerSizeUnits

The to parameter.

Returns

long

GetSizeInAutoString(double)

Returns a human-readable file size string with automatic unit selection.

public static string GetSizeInAutoString(double size)

Parameters

size double

The size parameter.

Returns

string

GetSizeInAutoString(double, ComputerSizeUnits)

A1 is input unit, not output

public static string GetSizeInAutoString(double value, ComputerSizeUnits fromUnit)

Parameters

value double
fromUnit ComputerSizeUnits

The source unit of measurement.

Returns

string

GetSizeInAutoString(long, ComputerSizeUnits)

Returns a human-readable file size string with automatic unit selection.

public static string GetSizeInAutoString(long value, ComputerSizeUnits fromUnit)

Parameters

value long

The value to process.

fromUnit ComputerSizeUnits

The fromUnit parameter.

Returns

string

GetTempFilePath()

path + file

public static string GetTempFilePath()

Returns

string

GetTokens(string)

Splits a path into its component tokens.

public static List<string> GetTokens(string relativePath)

Parameters

relativePath string

The relativePath parameter.

Returns

List<string>

GetUpFolderWhichContainsExtension(string, string)

Traverses up the directory tree to find a folder containing files with the specified extension.

public static string? GetUpFolderWhichContainsExtension(string path, string fileExt)

Parameters

path string

The file or directory path.

fileExt string

The fileExt parameter.

Returns

string

GroupFilesByName(List<string>)

Groups file paths by their file name.

public static Dictionary<string, List<string>> GroupFilesByName(List<string> filesInSubfolders)

Parameters

filesInSubfolders List<string>

The filesInSubfolders parameter.

Returns

Dictionary<string, List<string>>

HasAnyFoldersOrFiles(string)

Determines if a folder contains any files or subdirectories.

public static bool HasAnyFoldersOrFiles(string folder)

Parameters

folder string

The directory path.

Returns

bool

InsertBetweenFileNameAndExtension(string, string)

Inserts text between the file name and its extension.

public static string InsertBetweenFileNameAndExtension(string orig, string whatInsert)

Parameters

orig string

The orig parameter.

whatInsert string

The whatInsert parameter.

Returns

string

InsertBetweenFileNameAndExtensionRemovePath(string, string)

Vratí bez cesty, pouze název souboru Earlier name InsertBetweenFileNameAndExtension2

public static string InsertBetweenFileNameAndExtensionRemovePath(string orig, string whatInsert)

Parameters

orig string
whatInsert string

Returns

string

InsertBetweenFileNameAndPath(string, string, string)

Toto vkládá jako novou složku.

either A1 or A2 can be null
When A2 is null, will get from file path A1
public static string InsertBetweenFileNameAndPath(string folder, string parentFolder, string insert)

Parameters

folder string
parentFolder string
insert string

Returns

string

IsAbsolutePath(string)

Determines whether the specified path is an absolute path.

public static bool IsAbsolutePath(string path)

Parameters

path string

The file or directory path.

Returns

bool

IsAllInSameFolder(List<string>)

Determines if all paths in the list are in the same folder.

public static bool IsAllInSameFolder(List<string> paths)

Parameters

paths List<string>

The paths parameter.

Returns

bool

IsCountOfFilesMoreThan(string, string, int)

Checks if the number of files matching a pattern exceeds a threshold.

public static bool IsCountOfFilesMoreThan(string folderPath, string searchPattern, int getNullIfThereIsMoreThanXFiles)

Parameters

folderPath string

The folderPath parameter.

searchPattern string

The searchPattern parameter.

getNullIfThereIsMoreThanXFiles int

The getNullIfThereIsMoreThanXFiles parameter.

Returns

bool

IsExtension(string)

Determines whether the specified string is a valid file extension.

public static bool IsExtension(string result)

Parameters

result string

The result parameter.

Returns

bool

IsFileOlderThanXHours(string, int, bool)

Determines whether a file is older than the specified number of hours.

public static bool IsFileOlderThanXHours(string path, int hours, bool mustFileExists = false)

Parameters

path string

The file path to check.

hours int

The threshold number of hours.

mustFileExists bool

Whether to throw an exception if the file does not exist.

Returns

bool

IsWindowsPathFormat(string)

Usage: Exceptions.IsNotWindowsPathFormat

public static bool IsWindowsPathFormat(string argValue)

Parameters

argValue string

Returns

bool

KeepOnlyWhichIsNotInFiles(List<string>, List<string>)

Filters a list to keep only items not found in the specified files.

public static Task<List<string>> KeepOnlyWhichIsNotInFiles(List<string> opts, List<string> paths)

Parameters

opts List<string>

The list of options to filter.

paths List<string>

The list of file paths to compare against.

Returns

Task<List<string>>

LastModified(string)

Gets the last modified date and time of a file.

public static DateTime LastModified(string rel)

Parameters

rel string

The rel parameter.

Returns

DateTime

MakeFromLastPartFile(string, string)

Creates a file from the last part of a path with the specified extension.

public static string MakeFromLastPartFile(string fullPath, string ext)

Parameters

fullPath string

The fullPath parameter.

ext string

The ext parameter.

Returns

string

MakeUncLongPath(string)

Converts a path to UNC long path format to support paths longer than 260 characters.

public static string MakeUncLongPath(string path)

Parameters

path string

The file or directory path.

Returns

string

MakeUncLongPath(ref string)

Converts a path to UNC long path format to support paths longer than 260 characters.

public static string MakeUncLongPath(ref string path)

Parameters

path string

The file or directory path.

Returns

string

MascFromExtension(string)

Creates a wildcard search mask from a file extension.

public static string MascFromExtension(string ext2 = "*")

Parameters

ext2 string

The file extension or wildcard pattern to create a mask from.

Returns

string

MaskFromExtensions(List<string>)

Creates a wildcard search mask from a list of file extensions.

public static string MaskFromExtensions(List<string> allExtensions)

Parameters

allExtensions List<string>

The allExtensions parameter.

Returns

string

ModifiedinUnix(string)

Gets the last modified time of a file as a Unix timestamp.

public static long ModifiedinUnix(string filePath)

Parameters

filePath string

The file path.

Returns

long

MoveAllFilesRecursively(ILogger, string, string, FileMoveCollisionOption, string?)

Moves all files recursively from source to target directory.

[Obsolete("Use MoveDirectoryNoRecursive instead")]
public static void MoveAllFilesRecursively(ILogger logger, string sourcePath, string targetPath, FileMoveCollisionOption collisionOption, string? contains = null)

Parameters

logger ILogger

Logger instance for diagnostic messages.

sourcePath string

The source directory path.

targetPath string

The target directory path.

collisionOption FileMoveCollisionOption

How to handle file name collisions.

contains string

Optional filter string; only files containing this text are moved. Prefix with '!' for negation.

MoveAllRecursivelyAndThenDirectory(ILogger, string, string, FileMoveCollisionOption)

Moves all files recursively and then deletes the directory structure Throws exceptions, so must be called from try-catch block

public static void MoveAllRecursivelyAndThenDirectory(ILogger logger, string sourcePath, string targetPath, FileMoveCollisionOption collisionOption)

Parameters

logger ILogger

Logger instance

sourcePath string

Source directory path

targetPath string

Target directory path (root of target folder)

collisionOption FileMoveCollisionOption

File collision handling option

MoveDirectoryNoRecursive(ILogger, string, string, DirectoryMoveCollisionOption, FileMoveCollisionOption)

A1 i A2 musí končit backslashem Může vyhodit výjimku takže je nutné to odchytávat ve volající metodě If destination folder exists, source folder without files keep Return message if success, or null A5 false

public static string MoveDirectoryNoRecursive(ILogger logger, string from, string to, DirectoryMoveCollisionOption directoryMoveCollisionOption, FileMoveCollisionOption fileMoveCollisionOption)

Parameters

logger ILogger

Logger instance

from string

Source directory path

to string

Destination directory path

directoryMoveCollisionOption DirectoryMoveCollisionOption

Directory collision handling option

fileMoveCollisionOption FileMoveCollisionOption

File collision handling option

Returns

string

MoveDirectoryNoRecursive(string, string, DirectoryMoveCollisionOption, object)

Moves a directory without recursion.

public static void MoveDirectoryNoRecursive(string sourcePath, string targetPath, DirectoryMoveCollisionOption directoryMoveCollisionOption, object fileMoveCollisionOption)

Parameters

sourcePath string

The sourcePath parameter.

targetPath string

The targetPath parameter.

directoryMoveCollisionOption DirectoryMoveCollisionOption

The directoryMoveCollisionOption parameter.

fileMoveCollisionOption object

The fileMoveCollisionOption parameter.

MoveFile(ILogger, string, string, FileMoveCollisionOption)

A2 is path of target file

public static void MoveFile(ILogger logger, string sourceFilePath, string fileTo, FileMoveCollisionOption collisionOption)

Parameters

logger ILogger

Logger instance for diagnostic messages.

sourceFilePath string

The sourceFilePath parameter.

fileTo string
collisionOption FileMoveCollisionOption

MoveSubfoldersToFolder(ILogger, List<string>, string, string, FileMoveCollisionOption)

Moves specified subfolders from one location to another.

public static void MoveSubfoldersToFolder(ILogger logger, List<string> subfolderNames, string from, string to, FileMoveCollisionOption fo)

Parameters

logger ILogger

Logger instance for diagnostic messages.

subfolderNames List<string>

The subfolderNames parameter.

from string

The from parameter.

to string

The to parameter.

fo FileMoveCollisionOption

The fo parameter.

NormalizeExtension(string)

convert to lowercase and remove first dot - to už asi neplatí. Use NormalizeExtension2 for that

public static string NormalizeExtension(string extension)

Parameters

extension string

Returns

string

NormalizeExtension2(string)

Normalizes a file extension by converting to lowercase and removing the leading dot.

public static string NormalizeExtension2(string extension)

Parameters

extension string

The file extension to normalize.

Returns

string

NormalizeExtensions(List<string>)

convert to lowercase and remove first dot

public static void NormalizeExtensions(List<string> extension)

Parameters

extension List<string>

NumberByDateModified(ILogger, string, string, SearchOption)

Numbers files by their modification date.

public static void NumberByDateModified(ILogger logger, string folder, string searchPattern, SearchOption so)

Parameters

logger ILogger

Logger instance for diagnostic messages.

folder string

The directory path.

searchPattern string

The searchPattern parameter.

so SearchOption

The so parameter.

OnlyExtensionToLowerWithPath(string)

Gets the lowercase extension of a single file path.

public static string OnlyExtensionToLowerWithPath(string data)

Parameters

data string

The data parameter.

Returns

string

OnlyExtensions(List<string>)

Extracts only the extensions from a list of file paths.

public static List<string> OnlyExtensions(List<string> paths)

Parameters

paths List<string>

The paths parameter.

Returns

List<string>

OnlyExtensionsToLower(List<string>, GetExtensionArgs?)

Extracts extensions from file paths and converts them to lowercase.

public static List<string> OnlyExtensionsToLower(List<string> paths, GetExtensionArgs? args = null)

Parameters

paths List<string>

The list of file paths to extract extensions from.

args GetExtensionArgs

Optional arguments for controlling extension extraction behavior.

Returns

List<string>

OnlyExtensionsToLowerWithPath(List<string>)

Extracts lowercase extensions from file paths, preserving the path context.

public static List<string> OnlyExtensionsToLowerWithPath(List<string> paths)

Parameters

paths List<string>

The paths parameter.

Returns

List<string>

OnlyNames(List<string>)

Replaces full paths with just file names in the list.

public static void OnlyNames(List<string> subfolders)

Parameters

subfolders List<string>

The subfolders parameter.

OnlyNamesNoDirectEdit(List<string>)

No direct edit Returns with extension POZOR: Na rozdíl od stejné metody value sunamo tato metoda vrací úplně nové pole a nemodifikuje A1

public static List<string> OnlyNamesNoDirectEdit(List<string> files2)

Parameters

files2 List<string>

List of file paths.

Returns

List<string>

OnlyNamesNoDirectEdit(string, List<string>)

No direct edit

public static List<string> OnlyNamesNoDirectEdit(string appendToStart, List<string> fullPaths)

Parameters

appendToStart string
fullPaths List<string>

Returns

List<string>

OnlyNamesNoDirectEdit(string[])

No direct edit

public static List<string> OnlyNamesNoDirectEdit(string[] files2)

Parameters

files2 string[]

Returns

List<string>

OnlyNamesWithoutExtension(List<string>)

Direct edit

public static List<string> OnlyNamesWithoutExtension(List<string> path)

Parameters

path List<string>

The file or directory path.

Returns

List<string>

OnlyNamesWithoutExtension(string, List<string>)

Replaces full paths with file names without extensions.

public static List<string> OnlyNamesWithoutExtension(string appendToStart, List<string> fullPaths)

Parameters

appendToStart string

The appendToStart parameter.

fullPaths List<string>

The fullPaths parameter.

Returns

List<string>

OnlyNamesWithoutExtensionCopy(List<string>)

Returns a new list containing only file names without extensions.

public static List<string> OnlyNamesWithoutExtensionCopy(List<string> paths)

Parameters

paths List<string>

The paths parameter.

Returns

List<string>

OrderByNaturalNumberSerie(List<string>)

Normally: 11,12,1,2,... This: 1,2,...,11,12 non direct edit working with full paths or just filenames

public static List<string> OrderByNaturalNumberSerie(List<string> list)

Parameters

list List<string>

List of strings to order by natural number sequence

Returns

List<string>

PathSpecialAndLevel(string, string, int)

Constructs a path from base and relative segments up to a specified depth level.

public static string PathSpecialAndLevel(string basePath, string relativePath, int value)

Parameters

basePath string

The basePath parameter.

relativePath string

The relativePath parameter.

value int

The value to process.

Returns

string

PathWithoutExtension(string)

Returns the full path without the file extension.

public static string PathWithoutExtension(string path)

Parameters

path string

The file or directory path.

Returns

string

PlaceInFolder(string, string)

Places a file in a folder by combining the target folder path with the file's parent folder name and file name

public static string PlaceInFolder(string sourcePath, string targetFolder)

Parameters

sourcePath string

The source file path

targetFolder string

The target folder path

Returns

string

Combined path: targetFolder/parentFolderName/fileName

Postfix(string, string)

Appends a postfix to a file name before the extension.

public static string Postfix(string aPath, string text)

Parameters

aPath string

The aPath parameter.

text string

The text to process.

Returns

string

ReadAllText(string)

Reads all text content from a file.

public static Task<string> ReadAllText(string path)

Parameters

path string

The file path to read from.

Returns

Task<string>

RelativeToAbsolutePath(string, string)

count:\repos\EOM-7\Marvin\Module.VBtO\Clients\src\apps\vbto\src\pages\Administration\Administration.test.tsx ../../../../../../../node_modules/@mui/material/Switch/Switch => count:\repos\EOM-7\Marvin\Module.VBtO\Clients\node_modules@mui\material\Switch\Switch => OK

public static string RelativeToAbsolutePath(string fullPathToSecondFile, string relativePath)

Parameters

fullPathToSecondFile string
relativePath string

Returns

string

RemoveDiacriticInFileContents(string, string)

Removes diacritic marks from file contents in the specified folder.

public static Task RemoveDiacriticInFileContents(string folder, string mask)

Parameters

folder string

The directory path.

mask string

The file search mask pattern.

Returns

Task

RemoveDiacriticInFileSystemEntryNames(string)

Kromě jmen také zbavuje diakritiky složky.

public static void RemoveDiacriticInFileSystemEntryNames(string folder)

Parameters

folder string

RemoveFile(string)

Removes a file from disk.

public static string RemoveFile(string fullPathCsproj)

Parameters

fullPathCsproj string

The fullPathCsproj parameter.

Returns

string

RemoveSerieUnderscore(string)

Removes the underscore-style series suffix from a file name.

public static string RemoveSerieUnderscore(string data)

Parameters

data string

The data parameter.

Returns

string

RenameDirectory(ILogger, string, string, DirectoryMoveCollisionOption, FileMoveCollisionOption)

Může výhodit výjimku, proto je nutné používat value try-catch bloku Vrátí řetězec se zprávou kterou vypsat nebo null

public static string RenameDirectory(ILogger logger, string path, string newname, DirectoryMoveCollisionOption directoryCollisionOption, FileMoveCollisionOption fileCollisionOption)

Parameters

logger ILogger

Logger instance for diagnostic messages.

path string

The directory path to rename.

newname string

The new directory name.

directoryCollisionOption DirectoryMoveCollisionOption

How to handle directory name collisions.

fileCollisionOption FileMoveCollisionOption

How to handle file name collisions during the move.

Returns

string

RenameFile(ILogger, string, string, FileMoveCollisionOption)

A1,2 = with ext Physically rename file, this method is different from ChangeFilename in FileMoveCollisionOption A3 which can control advanced collision solution

public static void RenameFile(ILogger logger, string oldPath, string newFileNameWithoutPath, FileMoveCollisionOption collisionOption)

Parameters

logger ILogger

Logger instance for diagnostic messages.

oldPath string
newFileNameWithoutPath string
collisionOption FileMoveCollisionOption

RenameNumberedSerieFiles(ILogger, List<string>, List<string>, int, string)

A1 is new names of files without extension. Can use LinearHelper

public static void RenameNumberedSerieFiles(ILogger logger, List<string> data, List<string> files, int startFrom, string ext)

Parameters

logger ILogger

Logger instance

data List<string>

New names of files without extension

files List<string>

List of file paths to rename

startFrom int

Starting index for renaming

ext string

File extension

RenameNumberedSerieFiles(ILogger, List<string>, string, int, string)

RenameNumberedSerieFiles - Rename files by linear names - 0,1,...,x

public static void RenameNumberedSerieFiles(ILogger logger, List<string> data, string path, int startFrom, string ext)

Parameters

logger ILogger

Logger instance

data List<string>

New names of files without extension

path string

Directory path containing files

startFrom int

Starting index for renaming

ext string

File extension

RepairFilter(string)

txt files (.txt)|.txt|All files (.)|."

public static string RepairFilter(string filter)

Parameters

filter string

Returns

string

ReplaceDiacriticRecursive(ILogger, string, bool, bool, DirectoryMoveCollisionOption, FileMoveCollisionOption)

Recursively removes diacritic marks from file and folder names.

public static void ReplaceDiacriticRecursive(ILogger logger, string folder, bool dirs, bool files, DirectoryMoveCollisionOption directoryCollisionOption, FileMoveCollisionOption fileCollisionOption)

Parameters

logger ILogger

Logger instance for diagnostic messages.

folder string

The directory path.

dirs bool

The dirs parameter.

files bool

The files parameter.

directoryCollisionOption DirectoryMoveCollisionOption

The directoryCollisionOption parameter.

fileCollisionOption FileMoveCollisionOption

The fileCollisionOption parameter.

ReplaceDirectoryThrowExceptionIfFromDoesntExists(string, string, string)

change all first (drive) letter to uppercase

public static string ReplaceDirectoryThrowExceptionIfFromDoesntExists(string path, string folderWithProjectsFolders, string folderWithTemporaryMovedContentWithoutBackslash)

Parameters

path string

The file or directory path.

folderWithProjectsFolders string
folderWithTemporaryMovedContentWithoutBackslash string

Returns

string

ReplaceInAllFiles(IList<string>, IList<string>, ReplaceInAllFilesArgsBase, Func<string, bool>)

A4 - whether use text.Contains. A4 - SHReplace.ReplaceAll2

public static Task ReplaceInAllFiles(IList<string> replaceFrom, IList<string> replaceTo, ReplaceInAllFilesArgsBase args, Func<string, bool> EncodingHelperIsBinary)

Parameters

replaceFrom IList<string>

List of strings to find and replace.

replaceTo IList<string>

List of replacement strings.

args ReplaceInAllFilesArgsBase

Arguments controlling the replacement behavior.

EncodingHelperIsBinary Func<string, bool>

Function to determine if a file is binary.

Returns

Task

ReplaceInAllFiles(string, string, ReplaceInAllFilesArgsBase, Func<string, bool>)

Replaces text in all specified files.

public static Task ReplaceInAllFiles(string from, string to, ReplaceInAllFilesArgsBase args, Func<string, bool> EncodingHelperIsBinary)

Parameters

from string

The from parameter.

to string

The to parameter.

args ReplaceInAllFilesArgsBase

The args parameter.

EncodingHelperIsBinary Func<string, bool>

The EncodingHelperIsBinary parameter.

Returns

Task

ReplaceInAllFiles(string, string, List<string>, List<string>, bool, Func<string, bool>)

Replaces text in all specified files.

public static Task ReplaceInAllFiles(string folder, string extension, List<string> replaceFrom, List<string> replaceTo, bool isMultilineWithVariousIndent, Func<string, bool> EncodingHelperIsBinary)

Parameters

folder string

The directory path.

extension string

The extension parameter.

replaceFrom List<string>

The replaceFrom parameter.

replaceTo List<string>

The replaceTo parameter.

isMultilineWithVariousIndent bool

The isMultilineWithVariousIndent parameter.

EncodingHelperIsBinary Func<string, bool>

The EncodingHelperIsBinary parameter.

Returns

Task

ReplaceInFileName(string, string, string)

Náhrada za metodu ReplaceFileName se stejnými parametry

public static string ReplaceInFileName(string oldPath, string what, string forWhat)

Parameters

oldPath string
what string
forWhat string

Returns

string

ReplaceIncorrectCharactersFile(string)

Replacement can be configured with replaceIncorrectFor

public static string ReplaceIncorrectCharactersFile(string path)

Parameters

path string

The file path to process

Returns

string

ReplaceIncorrectCharactersFile(string, string)

Pro odstranění špatných znaků odstraní všechny výskyty A2 za mezery a udělá z více mezere jediné

public static string ReplaceIncorrectCharactersFile(string path, string replaceAllOfThisThen)

Parameters

path string

The file path to process

replaceAllOfThisThen string

Characters to replace with empty string

Returns

string

ReplaceIncorrectCharactersFile(string, string, string)

ReplaceIncorrectCharactersFile - can specify char for replace with ReplaceInvalidFileNameChars - all wrong chars skip A2 - can specify more letter in one string A3 is applicable only for A2. In general is use replaceIncorrectFor

public static string ReplaceIncorrectCharactersFile(string path, string replaceAllOfThisByA3, string replaceForThis)

Parameters

path string

The file path to process

replaceAllOfThisByA3 string

Characters to additionally replace

replaceForThis string

Replacement string

Returns

string

ReplaceInvalidFileNameChars(string, params char[])

ReplaceIncorrectCharactersFile - can specify char for replace with ReplaceInvalidFileNameChars - all wrong chars skip

public static string ReplaceInvalidFileNameChars(string filename, params char[] characters)

Parameters

filename string

The filename to process

characters char[]

Characters to keep even if they're invalid

Returns

string

Filename with invalid characters removed

SaveMemoryStream(MemoryStream, string)

Saves a memory stream to a file.

public static void SaveMemoryStream(MemoryStream mss, string path)

Parameters

mss MemoryStream

The mss parameter.

path string

The file or directory path.

SaveStream(string, Stream)

Saves a stream to a file at the specified path.

public static void SaveStream(string path, Stream text)

Parameters

path string

The file or directory path.

text Stream

The text to process.

ShrinkLongPath(string)

Shortens a long file path to a displayable length.

public static string ShrinkLongPath(string actualFilePath)

Parameters

actualFilePath string

The actualFilePath parameter.

Returns

string

Slash(string, bool)

A2 true - bs to slash. false - slash to bs

public static string Slash(string path, bool slash)

Parameters

path string

The path to process

slash bool

True to convert backslashes to slashes, false for opposite

Returns

string

SortPathsByFileName(List<string>, bool)

Sorts file paths alphabetically by their file name.

public static Dictionary<string, List<string>> SortPathsByFileName(List<string> allCsFilesInFolder, bool onlyOneExtension)

Parameters

allCsFilesInFolder List<string>

The allCsFilesInFolder parameter.

onlyOneExtension bool

The onlyOneExtension parameter.

Returns

Dictionary<string, List<string>>

StreamToArrayBytes(Stream)

Converts a stream to a byte array.

public static byte[] StreamToArrayBytes(Stream stream)

Parameters

stream Stream

The stream parameter.

Returns

byte[]

ThrowNotImplementedUwp()

Throws a not-implemented exception for UWP-specific operations.

public static void ThrowNotImplementedUwp()

ToSearchOption(bool?)

Converts a nullable boolean to a SearchOption value.

public static SearchOption ToSearchOption(bool? recursive)

Parameters

recursive bool?

The recursive parameter.

Returns

SearchOption

TrimBasePathAndTrailingBs(List<string>, string)

Removes the base path and trailing backslashes from a list of paths.

public static void TrimBasePathAndTrailingBs(List<string> text, string basePath)

Parameters

text List<string>

The text to process.

basePath string

The basePath parameter.

TrimContentInFilesOfFolder(string, string, SearchOption)

Trims whitespace from the content of all matching files in a folder.

public static void TrimContentInFilesOfFolder(string folder, string searchPattern, SearchOption searchOption)

Parameters

folder string

The directory path.

searchPattern string

The searchPattern parameter.

searchOption SearchOption

The searchOption parameter.

TryDeleteDirectory(string)

Before start you can create instance of PowershellRunner to try do it with PS

Vrátí true value případě chyby, jinak false

public static bool TryDeleteDirectory(string value)

Parameters

value string

The value to process.

Returns

bool

TryDeleteDirectoryOrFile(string)

Attempts to delete a path whether it is a file or directory.

public static bool TryDeleteDirectoryOrFile(string value)

Parameters

value string

The value to process.

Returns

bool

TryDeleteFile(string)

Attempts to delete a file, returning success status.

public static bool TryDeleteFile(string filePath)

Parameters

filePath string

The file path.

Returns

bool

TryDeleteFile(string, out string?)

Attempts to delete a file, returning success status.

public static bool TryDeleteFile(string filePath, out string? message)

Parameters

filePath string

The file path.

message string

The message parameter.

Returns

bool

TryDeleteWithRepetition(string)

Pokusí se max. 10x smazat soubor A1, pokud se nepodaří, GF, jinak GT

public static bool TryDeleteWithRepetition(string filePath)

Parameters

filePath string

Path to the file to delete

Returns

bool

WithEndSlash(string)

Ensures the path ends with a trailing backslash.

public static string WithEndSlash(string value)

Parameters

value string

The value to process.

Returns

string

WithEndSlash(ref string)

Usage: Exceptions.FileWasntFoundInDirectory

public static string WithEndSlash(ref string value)

Parameters

value string

The value to process.

Returns

string

WithoutEndSlash(string)

Removes trailing backslash from a path.

public static string WithoutEndSlash(string value)

Parameters

value string

The value to process.

Returns

string

WithoutEndSlash(ref string)

Removes trailing backslash from a path.

public static string WithoutEndSlash(ref string value)

Parameters

value string

The value to process.

Returns

string

WrapWithQm(string, bool?)

Wraps text with quote marks if needed

public static string WrapWithQm(string text, bool? forceNotIncludeQm)

Parameters

text string

Text to wrap

forceNotIncludeQm bool?

Force not to include quote marks

Returns

string

Text wrapped with quote marks if needed

WriteAllText(string, string)

Writes text content to a file.

public static Task WriteAllText(string path, string content)

Parameters

path string

The file or directory path.

content string

The content parameter.

Returns

Task

WriteAllTextWithExc(string, string)

Writes all text to file with exception handling

public static Task WriteAllTextWithExc(string file, string content)

Parameters

file string

The file path to write to

content string

The content to write

Returns

Task