using System.IO; namespace BansheeEngine { /// /// Contains various methods that provide handling for files not provided by System.File type. /// public static class FileEx { /// /// Moves a file from one path to another, while creating any parent directories if they don't already exist. /// /// Path to the file to move. /// New location and/or name of the file. public static void Move(string source, string destination) { string destParent = PathEx.GetParent(destination); if (!string.IsNullOrEmpty(destParent)) { if (!Directory.Exists(destParent)) Directory.CreateDirectory(destParent); } File.Move(source, destination); } /// /// Copies a file from one path to another, while creating any parent directories if they don't already exist. /// /// Path to the file to copy. /// Path to the copied file. public static void Copy(string source, string destination) { string destParent = PathEx.GetParent(destination); if (!string.IsNullOrEmpty(destParent)) { if (!Directory.Exists(destParent)) Directory.CreateDirectory(destParent); } File.Copy(source, destination); } } }