FileHelper

Namespace: Murder.Serialization
Assembly: Murder.dll

public static class FileHelper

FileHelper which will do OS operations. This is system-agnostic.

⭐ Methods

DeleteDirectoryIfExists(String&)

public bool DeleteDirectoryIfExists(String& path)

Parameters
path string&

Returns
bool

DeleteFileIfExists(String&)

public bool DeleteFileIfExists(String& path)

Parameters
path string&

Returns
bool

Exists(String&)

public bool Exists(String& path)

Parameters
path string&

Returns
bool

ExistsFromRelativePath(String&)

public bool ExistsFromRelativePath(String& relativePath)

Parameters
relativePath string&

Returns
bool

FileExists(String&)

public bool FileExists(String& path)

Parameters
path string&

Returns
bool

IsPathInsideOf(string, String[])

public bool IsPathInsideOf(string path, String[] filterFolders)

Parameters
path string
filterFolders string[]

Returns
bool

GetOrCreateDirectory(String&)

public DirectoryInfo GetOrCreateDirectory(String& path)

Parameters
path string&

Returns
DirectoryInfo

GuidFromName(string)

public Guid GuidFromName(string name)

Parameters
name string

Returns
Guid

GetAllFilesInFolder(string, bool, String[])

public IEnumerable<T> GetAllFilesInFolder(string path, bool recursive, String[] filters)

Parameters
path string
recursive bool
filters string[]

Returns
IEnumerable<T>

GetAllFilesInFolder(string, string, bool)

public IEnumerable<T> GetAllFilesInFolder(string path, string filter, bool recursive)

Parameters
path string
filter string
recursive bool

Returns
IEnumerable<T>

ListAllDirectories(string)

public IEnumerable<T> ListAllDirectories(string path)

Parameters
path string

Returns
IEnumerable<T>

DirectoryDeepCopy(string, string)

public int DirectoryDeepCopy(string sourceDirectoryPath, string destDirectoryPath)

Copies all files from to . Do not delete existing files.

Parameters
sourceDirectoryPath string

destDirectoryPath string

Returns
int

Exceptions
DirectoryNotFoundException

Normalize(string)

public Object Normalize(string source)

Used to normalize file paths from different OS into the same output.

Parameters
source string

Returns
Object

Clean(string)

public ReadOnlySpan<T> Clean(string str)

Parameters
str string

Returns
ReadOnlySpan<T>

ComputeHash(string)

public string ComputeHash(string filePath)

Computes a file Hash to watch it for changes

Parameters
filePath string

Returns
string

EscapePath(string)

public string EscapePath(string path)

Parameters
path string

Returns
string

ExtensionForOperatingSystem()

public string ExtensionForOperatingSystem()

Returns the assembly extension for the target operating system. For example, if targeting Windows, this returns ".dll".

Returns
string

Exceptions
PlatformNotSupportedException

GetPath(String[])

public string GetPath(String[] paths)

Gets the rooted path from a relative one

Parameters
paths string[]

Returns
string

GetPathWithoutExtension(string)

public string GetPathWithoutExtension(string path)

Parameters
path string

Returns
string

RemoveExtension(string)

public string RemoveExtension(string filePath)

Remove extension from a string.

Parameters
filePath string

Returns
string

SaveSerialized(T, string, bool)

public string SaveSerialized(T value, string path, bool isCompressed)

Parameters
value T
path string
isCompressed bool

Returns
string

SaveSerializedFromRelativePath(T, String&)

public string SaveSerializedFromRelativePath(T value, String& relativePath)

Parameters
value T
relativePath string&

Returns
string

DeserializeAsset(string)

public T DeserializeAsset(string path)

Parameters
path string

Returns
T

DeserializeGeneric(string, bool)

public T DeserializeGeneric(string path, bool warnOnErrors)

Parameters
path string
warnOnErrors bool

Returns
T

TryGetLastWrite(string)

public T? TryGetLastWrite(string path)

This will iterate recursively over all files in and return the latest modified date.

Parameters
path string

Returns
T?

SaveTextAsync(string, string)

public Task SaveTextAsync(string fullpath, string content)

Parameters
fullpath string
content string

Returns
Task

SaveSerializedAsync(T, string, bool)

public ValueTask<TResult> SaveSerializedAsync(T value, string path, bool isCompressed)

Parameters
value T
path string
isCompressed bool

Returns
ValueTask<TResult>

CreateDirectoryPathIfNotExists(string)

public void CreateDirectoryPathIfNotExists(string filePath)

This will create a directory on the root of this , if the directory is not available.

Parameters
filePath string

DeleteContent(String&, bool)

public void DeleteContent(String& fullpath, bool deleteRootFiles)

Parameters
fullpath string&
deleteRootFiles bool

OpenFolder(string)

public void OpenFolder(string path)

Parameters
path string

SaveText(String&, String&)

public void SaveText(String& fullpath, String& content)

Parameters
fullpath string&
content string&

SaveTextFromRelativePath(String&, String&)

public void SaveTextFromRelativePath(String& relativePath, String& content)

Parameters
relativePath string&
content string&