C# Path Combine(String, String, String, String)

Description

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

Syntax

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


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

Parameters

Path.Combine(String, 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.
  • path4 - The fourth path to combine.

Returns

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

Example

The following example combines four paths.


//  ww  w . j av  a2s.c o  m
using System;
using System.IO;
public class MainClass
{
    public static void Main(String[] argv)
    {
        string path1 = @"d:\archives\";
        string path2 = "a";
        string path3 = "b";
        string path4 = "c";
        string combinedPath = Path.Combine(path1, path2, path3, path4);
        Console.WriteLine(combinedPath);

    }
}
    

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