C# Path Combine(String, String, String)

Description

Path Combine(String, String, String) Combines three strings into a path.

Syntax

Path.Combine(String, String, String) has the following syntax.


public static string Combine(
  string path1,/*from   w  ww.j  a v  a  2s  .  c  o  m*/
  string path2,
  string path3
)

Parameters

Path.Combine(String, String, String) has the following parameters.

  • path1 - The first path to combine.
  • path2 - The second path to combine.
  • path3 - The third path to combine.

Returns

Path.Combine(String, String, String) method returns The combined paths.

Example

The following example combines three paths.


//from w w w.  j  av a2  s. c  om
using System;
using System.IO;
public class MainClass{
  public static void Main(String[] argv){  
    string p1 = @"d:\archives\";
    string p2 = "a";
    string p3 = "b";
    string combined = Path.Combine(p1, p2, p3);
    Console.WriteLine(combined);

  }
}
    

The code above generates the following result.





















Home »
  C# Tutorial »
    System.IO »




BinaryReader
BinaryWriter
Directory
DirectoryInfo
DriveInfo
File
FileInfo
FileStream
MemoryStream
Path
StreamReader
StreamWriter
StringReader
StringWriter