Combine Method (String, String)
Collapse the table of content
Expand the table of content

Path.Combine Method (String, String)

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Combines two path strings.

Namespace:  System.IO
Assembly:  mscorlib (in mscorlib.dll)

Public Shared Function Combine ( _
	path1 As String, _
	path2 As String _
) As String


Type: System.String
The first path.
Type: System.String
The second path.

Return Value

Type: System.String
A string containing the combined paths. If one of the specified paths is a zero-length string, this method returns the other path. If path2 contains an absolute path, this method returns path2.


path1 or path2 contain one or more of the invalid characters defined in GetInvalidPathChars.


path1 or path2 is Nothing.

If path1 does not end with a valid separator character as defined in DirectorySeparatorChar or AltDirectorySeparatorChar, a DirectorySeparatorChar is appended to path1 before concatenation.

If path2 does not include a root (for example, if path2 does not start with a separator character or a drive specification), the result is a concatenation of the two paths, with an intervening separator character. If path2 includes a root, path2 is returned.

The following example combines directory and subdirectory names into paths for creating the directories in isolated storage. This example is part of a larger example provided for the IsolatedStorageFile class.

' Create three subdirectories under MyApp1.
Dim subdirectory1 As String = Path.Combine("MyApp1", "SubDir1")
Dim subdirectory2 As String = Path.Combine("MyApp1", "SubDir2")
Dim subdirectory3 As String = Path.Combine("MyApp1", "SubDir3")

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

© 2017 Microsoft