Επεξεργασία

Κοινή χρήση μέσω


FileSystem.CombinePath(String, String) Method

Definition

Combines two paths and returns a properly formatted path.

public:
 static System::String ^ CombinePath(System::String ^ baseDirectory, System::String ^ relativePath);
public static string CombinePath (string baseDirectory, string? relativePath);
public static string CombinePath (string baseDirectory, string relativePath);
static member CombinePath : string * string -> string
Public Shared 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 an example of a task involving the My.Computer.FileSystem.CombinePath method.

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

Applies to

See also