Class PathHelper
Helpers for working with file/folder paths.
Inheritance
Namespace: Kros.IO
Assembly: Kros.Utils.dll
Syntax
public static class PathHelper
Methods
BuildPath(String[])
Joins parts parts to one string, representing path to a file/folder.
Declaration
public static string BuildPath(params string[] parts)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String[] | parts | Path parts. |
Returns
| Type | Description |
|---|---|
| System.String | Created path. |
Remarks
The method works similarly as standard .NET method System.IO.Path.Combine(System.String[]), with some different details:
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | The value of |
| System.ArgumentException | Any of the item in |
GetTempPath()
Returns path to system temporary folder (System.IO.Path.GetTempPath) without trailing directory separator.
Declaration
public static string GetTempPath()
Returns
| Type | Description |
|---|---|
| System.String |
IsNetworkPath(String)
Checks, if specified path is network share path. The path is considered network share path,
if it begins with \.
Declaration
public static bool IsNetworkPath(string path)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | path | Checked path. |
Returns
| Type | Description |
|---|---|
| System.Boolean | true if |
ReplaceInvalidPathChars(String)
Replaces invalid characters in pathName with dash (-). If there are
several succesive invalid characters, they all are replaced only by one dash.
Declaration
public static string ReplaceInvalidPathChars(string pathName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | pathName | Input path. |
Returns
| Type | Description |
|---|---|
| System.String |
Remarks
ReplaceInvalidPathChars(String, String)
Replaces invalid characters in pathName with replacement. If there are
several succesive invalid characters, they all are replaced only by one replacement.
Declaration
public static string ReplaceInvalidPathChars(string pathName, string replacement)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | pathName | Input path. |
| System.String | replacement | Value, by which are replaced invalid path charactes. If the value is null, empty stirng is used, so invalid characters are removed. |
Returns
| Type | Description |
|---|---|
| System.String | String with invalid path characters replaced. If input |
Remarks
Replaced are all characters in System.IO.Path.GetInvalidFileNameChars and System.IO.Path.GetInvalidPathChars.