Redigera

Dela via


FileSystemProxy.CombinePath(String, String) Method

Definition

Combines two paths and returns a properly formatted path.

public:
 System::String ^ CombinePath(System::String ^ baseDirectory, System::String ^ relativePath);
public string CombinePath (string baseDirectory, string relativePath);
member this.CombinePath : string * string -> string
Public Function CombinePath (baseDirectory As String, relativePath As String) As String

Parameters

baseDirectory
String

String. First path to be combined.

relativePath
String

String. Second path to be combined.

Returns

The combination of the specified paths.

Exceptions

baseDirectory or relativePath are malformed paths.

Examples

This example combines a directory path and file name to create a properly formatted path.

Dim fullPath = My.Computer.FileSystem.CombinePath(
    "C:\Documents and Settings\All Users\Documents\My Pictures", "picture.jpg")

This example combines two paths to create a properly formatted path.

Dim fullPath = My.Computer.FileSystem.CombinePath(
    "C:\Dir1\Dir2\Dir3", "..\Dir4\Dir5\File.txt")

This example returns C:\Dir1\Dir2\Dir4\Dir5\File.txt.

Remarks

This method trims excess slash-mark characters to create a properly formatted path.

The following table lists examples of tasks involving the My.Computer.FileSystem.CombinePath method.

To See
Combine a directory path and file name How to: Parse File Paths

Applies to

See also