Combine two strings into a path in CSharp
Description
The following code shows how to combine two strings into a path.
Example
/*from w w w. j a v a 2s. c om*/
using System;
using System.IO;
public class MainClass {
public static void Main() {
string path1 = "c:\\temp";
string path2 = "subdir\\file.txt";
string combination = Path.Combine(path1, path2);
Console.WriteLine(combination);
}
}
The code above generates the following result.