Combine three strings into a path in CSharp

Description

The following code shows how to combine three strings into a path.

Example


  //w ww  .j  a  v a2 s  .  c  o m
  
  
     

using System;
using System.IO;

public class MainClass {

    public static void Main() {
            string p1 = @"c:\a\";
            string p2 = "media";
            string p3 = "images";
            string combined = Path.Combine(p1, p2, p3);
            Console.WriteLine(combined);
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    IO »




File Attribute
File Security
Directory Attribute
Directory Recursive
Binary File
Text Field
Buffered IO
Create Copy Delete Move
CSV
Drive
File System Watcher
Isolated Storage
MemoryStream
Serialize
Zip