CSharp examples for File IO:Directory
Moves a directory from one path to another, while creating any parent directories if they don't already exist.
//**************** Copyright (c) 2016 Marko Pintera (marko.pintera@gmail.com). All rights reserved. **********************// using System.IO;/*from w w w. j a v a2 s . c o m*/ public class Main{ /// <summary> /// Moves a directory from one path to another, while creating any parent directories if they don't already exist. /// </summary> /// <param name="source">Path to the directory to move.</param> /// <param name="destination">New location and/or name of the directory.</param> public static void Move(string source, string destination) { string destParent = PathEx.GetParent(destination); if (!string.IsNullOrEmpty(destParent)) { if (!Directory.Exists(destParent)) Directory.CreateDirectory(destParent); } Directory.Move(source, destination); } }