Path.Combine Method (String, String)
May 11, 2014
Combines two path strings.
Assembly: mscorlib (in mscorlib.dll)
Return ValueType: 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.
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. string subdirectory1 = Path.Combine("MyApp1", "SubDir1"); string subdirectory2 = Path.Combine("MyApp1", "SubDir2"); string subdirectory3 = Path.Combine("MyApp1", "SubDir3"); store.CreateDirectory(subdirectory1); store.CreateDirectory(subdirectory2); store.CreateDirectory(subdirectory3);