Combine an array of strings into a path in CSharp

Description

The following code shows how to combine an array of strings into a path.

Example


  /*from w w  w.java2s .c om*/
  
  
     
using System;
using System.IO;

public class MainClass {

    public static void Main() {

        string[] paths = {@"c:\a", "2001", "media", "images"};
        string fullPath = Path.Combine(paths);
        Console.WriteLine(fullPath);
    }
}

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