Table of Contents

Class PathExtensions

Namespace
Acuit.Pinpoint.Common
Assembly
Acuit.Pinpoint.Common.dll

Extensions to the System.IO.Path class.

public static class PathExtensions
Inheritance
PathExtensions
Inherited Members

Methods

GetUnusedFileName(string, Func<string, bool>)

Gets an unused file name, appending " (1)", " (2)", etc., to the file name as necessary.

public static string GetUnusedFileName(string fileName, Func<string, bool> isUsedDelegate)

Parameters

fileName string

The preferred file name to use. This should not include a path.

isUsedDelegate Func<string, bool>

A delegate that yields whether a file name is used.

Returns

string

The unused file name.

Exceptions

ArgumentNullException

fileName is null.

ArgumentNullException

isUsedDelegate is null.

SanitizeFileName(string)

Sanitizes a proposed file name so that it does not use any invalid file name characters.

public static string SanitizeFileName(string fileName)

Parameters

fileName string

The file name to sanitize.

Returns

string

The sanitized file name.

Remarks

All invalid characters will be replaced by an underscore ("_"), and leading and trailing whitespace will be trimmed.

Exceptions

ArgumentNullException

fileName is null.

SanitizeFileName(string, string)

Sanitizes a proposed file name so that it does not use any invalid file name characters.

public static string SanitizeFileName(string fileName, string defaultFileName)

Parameters

fileName string

The file name to sanitize.

defaultFileName string

A default file name to use if the resulting sanitized name does not contain any original non-whitespace characters left.

Returns

string

The sanitized file name.

Remarks

All invalid characters will be replaced by an underscore ("_"), and leading and trailing whitespace will be trimmed.

Exceptions

ArgumentNullException

fileName is null.

ArgumentNullException

defaultFileName is null.