Provides Equals and Compare operations for strings which represent filesystem paths.
Paths can be null, relative or rooted, local or UNC, can contain long names or shortened 8.3 names.
Paths can point to directory or file, existing or not (but see Remarks).
This class implements IComparer{string} and can be used as a comparer for hash- or comparator-based
collections (like Dictionary{string, T} where paths are keys) or algorithms which store or operate on file system paths.
Inheritance Hierarchy SystemObject
PDTec.IceNet.Sdk.UtilsPathComparer
Namespace:
PDTec.IceNet.Sdk.Utils
Assembly:
PDTec.IceNet.Sdk (in PDTec.IceNet.Sdk.dll) Version: 7.2.0.0 (7.2.7583.15464)
Syntax public class PathComparer : IComparer<string>
The PathComparer type exposes the following members.
Constructors
| Name | Description |
---|
| PathComparer | Initializes a new instance of the PathComparer class |
TopMethods
| Name | Description |
---|
| Compare |
Lexicographically compares two strings for relative order.
|
| Equals(Object) | Determines whether the specified object is equal to the current object. (Inherited from Object.) |
| Equals(String, String) |
Compares two strings which represent file system paths for equality.
|
| Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
| GetHashCode | Serves as the default hash function. (Inherited from Object.) |
| GetHashCode(String) |
Calculate hash code of a file system path.
|
| GetType | Gets the Type of the current instance. (Inherited from Object.) |
| MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
| Normalize |
Converts path to its normalized representation:
- Converts relative path to absolute path, using current directory and current drive information
- Replaces 'dot' path segments ('.' and '..') with appropriate directories
- Converts directory separators to primary directory separator
- Converts shortened 8.3 names to long names
- Strips trailing directory separators
- It's not required to normalize casing
|
| ToString | Returns a string that represents the current object. (Inherited from Object.) |
TopRemarks
Path strings passed to functions of this class are normalized with
GetFullPath(String) method, what
causes following issues:
- Before comparison is performed, relative paths are expanded to absolute ones, with regard to current working directory
- '.' and '..' path entries are resolved appropriately
- Target file or directory is not required to exists, but if it exists, sufficient permissions are required to access path information
- If path contains shortened 8.3 names, they are expanded to long names only if file or directory specified by a path exists
Path strings are compared with case-insensitive, culture independent (ordinal-based) string comparer. This behaviour is
not applicable for
case-sensitive file systems.
See Also Reference
PathGetFullPath(String)