C# Class Catel.IO.Path

Static class that implements some path methods
Show file Open project: Catel/Catel Class Usage Examples

Public Methods

Method Description
AppendTrailingSlash ( string path ) : string

Appends a trailing backslash (\) to the path.

AppendTrailingSlash ( string path, char slash ) : string

Appends a trailing slash (\ or /) to the path.

Combine ( ) : string

Returns a combination of multiple paths.

CombineUrls ( ) : string

Returns a combination of multiple urls.

GetApplicationDataDirectory ( ) : string

Gets the application data directory for the company and product as defined the the assembly information of the entry assembly. If the entry assembly is null, this method will fall back to the calling assembly to retrieve the information. If the folder does not exist, the folder is automatically created by this method. This method returns a value like [application data]\[company]\[product name].

GetApplicationDataDirectory ( ApplicationDataTarget applicationDataTarget ) : string

Gets the application data directory for the company and product as defined the the assembly information of the entry assembly. If the entry assembly is null, this method will fall back to the calling assembly to retrieve the information. If the folder does not exist, the folder is automatically created by this method. This method returns a value like [application data]\[company]\[product name].

GetApplicationDataDirectory ( ApplicationDataTarget applicationDataTarget, string productName ) : string

Gets the application data directory for a specific product. If the folder does not exist, the folder is automatically created by this method. This method returns a value like [application data]\[product name].

GetApplicationDataDirectory ( ApplicationDataTarget applicationDataTarget, string companyName, string productName ) : string

Gets the application data directory for a specific product of a specific company. If the folder does not exist, the folder is automatically created by this method. This method returns a value like [application data]\[company]\[product name].

GetApplicationDataDirectory ( string productName ) : string

Gets the application data directory for a specific product. If the folder does not exist, the folder is automatically created by this method. This method returns a value like [application data]\[product name].

GetApplicationDataDirectory ( string companyName, string productName ) : string

Gets the application data directory for a specific product of a specific company. If the folder does not exist, the folder is automatically created by this method. This method returns a value like [application data]\[company]\[product name].

GetApplicationDataDirectoryForAllUsers ( ) : string

Gets the application data directory for the company and product as defined the the assembly information of the entry assembly. If the entry assembly is null, this method will fall back to the calling assembly to retrieve the information. If the folder does not exist, the folder is automatically created by this method. This method returns a value like [application data]\[company]\[product name].

GetApplicationDataDirectoryForAllUsers ( string productName ) : string

Gets the application data directory for a specific product. If the folder does not exist, the folder is automatically created by this method. This method returns a value like [application data]\[product name].

GetApplicationDataDirectoryForAllUsers ( string companyName, string productName ) : string

Gets the application data directory for a specific product of a specific company. If the folder does not exist, the folder is automatically created by this method. This method returns a value like [application data]\[company]\[product name].

GetDirectoryName ( string path ) : string

Gets the name of the directory.

GetFileName ( string path ) : string

Gets the name of the file.

GetFullPath ( string relativePath, string basePath ) : string

Returns the full path for a relative path.

GetParentDirectory ( string path ) : string

Gets the parent directory.

This method will always strip the trailing backslash from the parent.

GetRelativePath ( string fullPath, string basePath = null ) : string

Returns a relative path string from a full path. The path to convert. Can be either a file or a directory The base path to truncate to and replace Lower case string of the relative path. If path is a directory it's returned without a backslash at the end. Examples of returned values: .\test.txt, ..\test.txt, ..\..\..\test.txt, ., ..

Private Methods

Method Description
RemoveStartAndTrailingSlashes ( string value ) : string

Removes any slashes (\ or /) at the beginning and end of the string.

RemoveStartSlashes ( string value ) : string

Removes any slashes (\ or /) at the beginning of the string.

RemoveTrailingSlashes ( string value ) : string

Removes any slashes (\ or /) at the end of the string.

ReplacePathSlashesByUrlSlashes ( string value ) : string

Replaces path slashes (\) by url slashes (/).

Method Details

AppendTrailingSlash() public static method

Appends a trailing backslash (\) to the path.
The is null or whitespace.
public static AppendTrailingSlash ( string path ) : string
path string Path to append the trailing backslash to.
return string

AppendTrailingSlash() public static method

Appends a trailing slash (\ or /) to the path.
The is null or whitespace.
public static AppendTrailingSlash ( string path, char slash ) : string
path string Path to append the trailing slash to.
slash char Slash to append (\ or /).
return string

Combine() public static method

Returns a combination of multiple paths.
public static Combine ( ) : string
return string

CombineUrls() public static method

Returns a combination of multiple urls.
public static CombineUrls ( ) : string
return string

GetApplicationDataDirectory() public static method

Gets the application data directory for the company and product as defined the the assembly information of the entry assembly. If the entry assembly is null, this method will fall back to the calling assembly to retrieve the information. If the folder does not exist, the folder is automatically created by this method. This method returns a value like [application data]\[company]\[product name].
public static GetApplicationDataDirectory ( ) : string
return string

GetApplicationDataDirectory() public static method

Gets the application data directory for the company and product as defined the the assembly information of the entry assembly. If the entry assembly is null, this method will fall back to the calling assembly to retrieve the information. If the folder does not exist, the folder is automatically created by this method. This method returns a value like [application data]\[company]\[product name].
public static GetApplicationDataDirectory ( ApplicationDataTarget applicationDataTarget ) : string
applicationDataTarget ApplicationDataTarget
return string

GetApplicationDataDirectory() public static method

Gets the application data directory for a specific product. If the folder does not exist, the folder is automatically created by this method. This method returns a value like [application data]\[product name].
public static GetApplicationDataDirectory ( ApplicationDataTarget applicationDataTarget, string productName ) : string
applicationDataTarget ApplicationDataTarget The application data target.
productName string Name of the product.
return string

GetApplicationDataDirectory() public static method

Gets the application data directory for a specific product of a specific company. If the folder does not exist, the folder is automatically created by this method. This method returns a value like [application data]\[company]\[product name].
public static GetApplicationDataDirectory ( ApplicationDataTarget applicationDataTarget, string companyName, string productName ) : string
applicationDataTarget ApplicationDataTarget The application data target.
companyName string Name of the company.
productName string Name of the product.
return string

GetApplicationDataDirectory() public static method

Gets the application data directory for a specific product. If the folder does not exist, the folder is automatically created by this method. This method returns a value like [application data]\[product name].
public static GetApplicationDataDirectory ( string productName ) : string
productName string Name of the product.
return string

GetApplicationDataDirectory() public static method

Gets the application data directory for a specific product of a specific company. If the folder does not exist, the folder is automatically created by this method. This method returns a value like [application data]\[company]\[product name].
public static GetApplicationDataDirectory ( string companyName, string productName ) : string
companyName string Name of the company.
productName string Name of the product.
return string

GetApplicationDataDirectoryForAllUsers() public static method

Gets the application data directory for the company and product as defined the the assembly information of the entry assembly. If the entry assembly is null, this method will fall back to the calling assembly to retrieve the information. If the folder does not exist, the folder is automatically created by this method. This method returns a value like [application data]\[company]\[product name].
public static GetApplicationDataDirectoryForAllUsers ( ) : string
return string

GetApplicationDataDirectoryForAllUsers() public static method

Gets the application data directory for a specific product. If the folder does not exist, the folder is automatically created by this method. This method returns a value like [application data]\[product name].
public static GetApplicationDataDirectoryForAllUsers ( string productName ) : string
productName string Name of the product.
return string

GetApplicationDataDirectoryForAllUsers() public static method

Gets the application data directory for a specific product of a specific company. If the folder does not exist, the folder is automatically created by this method. This method returns a value like [application data]\[company]\[product name].
public static GetApplicationDataDirectoryForAllUsers ( string companyName, string productName ) : string
companyName string Name of the company.
productName string Name of the product.
return string

GetDirectoryName() public static method

Gets the name of the directory.
The is null or whitespace.
public static GetDirectoryName ( string path ) : string
path string The path to get the directory name from.
return string

GetFileName() public static method

Gets the name of the file.
The is null or whitespace.
public static GetFileName ( string path ) : string
path string The path to get the file name from.
return string

GetFullPath() public static method

Returns the full path for a relative path.
The is null or whitespace. The is null or whitespace.
public static GetFullPath ( string relativePath, string basePath ) : string
relativePath string Relative path to convert to a full path.
basePath string Base path (a.k.a. working directory).
return string

GetParentDirectory() public static method

Gets the parent directory.
This method will always strip the trailing backslash from the parent.
public static GetParentDirectory ( string path ) : string
path string The path to get the parent directory from.
return string

GetRelativePath() public static method

Returns a relative path string from a full path. The path to convert. Can be either a file or a directory The base path to truncate to and replace Lower case string of the relative path. If path is a directory it's returned without a backslash at the end. Examples of returned values: .\test.txt, ..\test.txt, ..\..\..\test.txt, ., ..
The is null or whitespace.
public static GetRelativePath ( string fullPath, string basePath = null ) : string
fullPath string Full path to convert to relative path.
basePath string The base path (a.k.a. working directory). If this parameter is null or empty, the current working directory will be used.
return string