Export (0) Print
Expand All

FileSystem.CombinePath Method

Combines two paths and returns a properly formatted path.

Namespace:  Microsoft.VisualBasic.FileIO
Assembly:  Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)

public static string CombinePath(
	string baseDirectory,
	string relativePath
)

Parameters

baseDirectory
Type: System.String

String. First path to be combined.

relativePath
Type: System.String

String. Second path to be combined.

Return Value

Type: System.String
The combination of the specified paths.

ExceptionCondition
ArgumentException

baseDirectory or relativePath are malformed paths.

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

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.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Show:
© 2015 Microsoft