Click or drag to resize

PathLocalToUnc Method (String, Boolean, Boolean, Boolean)

[AlphaFS] Converts a local path to a network share path, optionally returning it in a long path format and the ability to add or remove a trailing backslash.

A Local path, e.g.: "C:\Windows" will be returned as: "\\MachineName\C$\Windows".

If a logical drive points to a network share path, the share path will be returned instead.

Namespace:  Alphaleonis.Win32.Filesystem
Assembly:  AlphaFS (in AlphaFS.dll) Version: 2.0
public static string LocalToUnc(
	string localPath,
	bool asLongPath,
	bool addTrailingDirectorySeparator,
	bool removeTrailingDirectorySeparator


Type: SystemString
A local path, e.g.: "C:\Windows".
Type: SystemBoolean
returns the path in long path (Unicode) format, when returns the path as a regular path.
Type: SystemBoolean
adds a trailing DirectorySeparatorChar character to localPath, when absent.
Type: SystemBoolean
removes the trailing DirectorySeparatorChar character from localPath, when present.

Return Value

Type: String
On successful conversion a UNC path is returned.

If the conversion fails, localPath is returned.

If localPath is an empty string or , is returned.

See Also