IOUtilities Class

public static class IOUtilities

No documentation is available.

Methods

NameDescription
CopyDirectory(DirectoryInfo, DirectoryInfo)Copies a directory and its content to a new location.
CopyDirectory(string, string)Copies a directory and its content to a new location.
Delete(FileSystemInfo)
Delete(string)
DeleteAsync(FileSystemInfo, CancellationToken)
DeleteAsync(string, CancellationToken)
IsSharingViolation(IOException)Determines whether the specified exception is a sharing violation exception.
PathCreateDirectory(string)Makes sure a directory exists for a given file path.
PathUnprotect(string)Unprotects the given file path.
ToValidFileName(string, string, string)Converts a text into a valid file name.

CopyDirectory overloads

CopyDirectory(DirectoryInfo, DirectoryInfo)

IOUtilities.cs

Copies a directory and its content to a new location.

public static void CopyDirectory(DirectoryInfo source, DirectoryInfo destination)
Parameters
source DirectoryInfo
destination DirectoryInfo
Remarks

Symbolic links to directories are copied as links instead of being followed, as cp -R does.

CopyDirectory(string, string)

IOUtilities.cs

Copies a directory and its content to a new location.

public static void CopyDirectory(string sourcePath, string destinationPath)
Parameters
sourcePath string
destinationPath string
Remarks

Symbolic links to directories are copied as links instead of being followed, as cp -R does.

Delete overloads

Delete(FileSystemInfo)

IOUtilities.Delete.cs
public static void Delete(FileSystemInfo fileSystemInfo)
Parameters
fileSystemInfo FileSystemInfo

No documentation is available.

Delete(string)

IOUtilities.Delete.cs
public static void Delete(string path)
Parameters
path string

No documentation is available.

DeleteAsync overloads

DeleteAsync(FileSystemInfo, CancellationToken)

IOUtilities.Delete.cs

net10.0

public static ValueTask DeleteAsync(FileSystemInfo fileSystemInfo, CancellationToken cancellationToken = default)

net11.0

public static ValueTask DeleteAsync(FileSystemInfo fileSystemInfo, CancellationToken cancellationToken = default)
Parameters
fileSystemInfo FileSystemInfo
cancellationToken CancellationToken
Returns

ValueTask

No documentation is available.

DeleteAsync(string, CancellationToken)

IOUtilities.Delete.cs
public static ValueTask DeleteAsync(string path, CancellationToken cancellationToken = default)
Parameters
path string
cancellationToken CancellationToken
Returns

ValueTask

No documentation is available.

IsSharingViolation(IOException)

IOUtilities.Delete.cs

Determines whether the specified exception is a sharing violation exception.

public static bool IsSharingViolation(IOException exception)

Parameters

exception IOException
The exception. May not be null.

Returns

bool true if the specified exception is a sharing violation exception; otherwise, false.

PathCreateDirectory(string)

IOUtilities.cs

Makes sure a directory exists for a given file path.

public static void PathCreateDirectory(string filePath)

Parameters

filePath string
The file path. Note this is not to be confused with the directory path. May not be null.

PathUnprotect(string)

IOUtilities.cs

Unprotects the given file path.

public static void PathUnprotect(string path)

Parameters

path string
The file path. May not be null.

ToValidFileName(string, string, string)

IOUtilities.cs

Converts a text into a valid file name.

public static string ToValidFileName(string fileName, string reservedNameFormat = "_{0}_", string reservedCharFormat = "_x{0}_")

Parameters

fileName string
The file name.
reservedNameFormat string
The reserved format to use for reserved names. If null '_{0}_' will be used.
reservedCharFormat string
The reserved format to use for reserved characters. If null '_x{0}_' will be used.

Returns

string A valid file name.