Compartir a través de


PathUtil Class

Definition

This type is forwarded from MS.VS.Shell.xx.dll

public ref class PathUtil abstract sealed
public ref class PathUtil abstract sealed
class PathUtil abstract sealed
public static class PathUtil
type PathUtil = class
Public Module PathUtil
Inheritance
PathUtil

Methods

ArePathsEqual(String, String)

Determines if two paths are equal. This method does not treat Path.DirectorySeparatorChar and Path.AltDirectorySeparatorChar as equivalent.

ContainsReparsePoint(String, String)

Determines if any level in the given path is a Junction, up to pathRoot (pathRoot itself will not be included in the determination)

DerelativizePath(String, String)

Combines a relative path with a base path to return a rooted version of the relative path, collapsing any ".." segments that appear at the beginning of the relative path.

GetCommonPathPrefix(String, String)

Returns the longest leading string that is common to path1 and path2. Case is not considered in the comparison.

GetFileSystemCasing(String)

Returns the path with casing that matches what's on the file system.

HasInvalidChars(String)

Returns whether path contains any invalid path characters. This method uses a cached array, in contrast to GetInvalidPathChars(), which allocates a new array for each call.

IsDescendant(String, String)

Indicates whether the a child path is a descendant of a parent directory. This is a purely textual computation indicating that the child could be a descendant of the parent; there is no file system interaction to determine whether child actually is a descendant of parent.

IsDirectorySeparator(Char)

Determines if a character is a directory separator

IsImplicitDirectory(String)

Determines if the given directory is one of the implicit directories contained in all directories (i.e. "." or "..")

IsNormalized(String)

Indicates whether the given path is in normalized form.

IsNormalizedPath(String)

Extension method to check whether the given path is in normalized form.

IsReparsePoint(String)

Determines if the given path is a Junction.

IsRoot(String)

Determines if the given path represents a root directory.

LooksLikeLocalRootedFilePath(String)

Heuristically determines whether the given string "looks like" a local rooted file path -- e.g. begins with a drive letter followed by ":", contains only valid path characters, etc.

MakeRelative(String, String)

Returns a relative path from relativePathBase to pathToRelativize. The parameters are treated as folders if they end in "", otherwise as filenames. The path from c:\foo\bar to c:\cat\dog is ..\cat\dog -- NOT ....\cat\dog because "bar" and "dog" are files, not folders. If "bar" is a folder, you must append "" to ask for the path from c:\foo\bar\ to c:\cat\dog -- THEN the answer will be ....\cat\dog.

Normalize(String)

Returns a normalized form of the given path.

What it does:

  • Takes pains not to allocate extra temporary strings.
  • Verifies that the path contains no invalid path characters, throwing an exception if any invalid characters are found.
  • Strips leading and trailing whitespace.
  • Replaces "/" with ""
  • Replaces multiple consecutive "" with a single "", except for the leading "\" of a UNC path.
  • Removes the trailing "", unless it's part of a root (e.g. "C:")
  • Converts to lowercase

What it doesn't do:

  • Fully qualify a non-rooted filename (e.g. "dir\filename.ext")
  • Simplify relative pathnames (e.g. "C:\dir..\FileInDriveRoot.ext"). It's tempting to use Path.GetFullPathName to perform this function, but that would entail an expensive trip to the disk or network.
  • Verify that the path exists.
NormalizePath(String)

Extension method to return a normalized form of the given path.

SafeGetExtension(String)

Return the extension of the specified path string. This always returns a non-null string for the extension. It will return Empty if:

*   <code data-dev-comment-type="paramref">path</code> is null 
*   <code data-dev-comment-type="paramref">path</code> is empty
*   <code data-dev-comment-type="paramref">path</code> does not contain an extension

Otherwise, path's extension (including the period ".").

Applies to