FAES/Utilities/FileAES_IntUtilities.cs
/// <summary>
/// Copies a directory to another location
/// </summary>
/// <param name="sourceDirName">Source directory to copy</param>
/// <param name="destDirName">Destination directory</param>
/// <param name="firstPass">Whether the current run of this method is the first one</param>
Copies a directory to another location
Copies a directory to another location
internal static void DirectoryCopy(string sourceDirName, string destDirName, bool firstPass = true)
        {
            DirectoryInfo dir = new DirectoryInfo(sourceDirName);
            if (!dir.Exists) return;
            DirectoryInfo[] dirs = dir.GetDirectories();
            if (!Directory.Exists(destDirName)) Directory.CreateDirectory(destDirName);
            if (firstPass)
            {
                string newDest = Path.Combine(destDirName, new DirectoryInfo(sourceDirName).Name);
                Directory.CreateDirectory(newDest);
                destDirName = newDest;
            }
            FileInfo[] files = dir.GetFiles();
            foreach (FileInfo file in files) file.CopyTo(Path.Combine(destDirName, file.Name), false);
            foreach (DirectoryInfo subDir in dirs) DirectoryCopy(subDir.FullName, Path.Combine(destDirName, subDir.Name), false);
        }
internal static void DirectoryCopy ( string sourceDirName , string destDirName , bool firstPass = true ) { DirectoryInfo dir = new DirectoryInfo ( sourceDirName ) ; if ( ! dir . Exists ) return ; DirectoryInfo [ ] dirs = dir . GetDirectories ( ) ; if ( ! Directory . Exists ( destDirName ) ) Directory . CreateDirectory ( destDirName ) ; if ( firstPass ) { string newDest = Path . Combine ( destDirName , new DirectoryInfo ( sourceDirName ) . Name ) ; Directory . CreateDirectory ( newDest ) ; destDirName = newDest ; } FileInfo [ ] files = dir . GetFiles ( ) ; foreach ( FileInfo file in files ) file . CopyTo ( Path . Combine ( destDirName , file . Name ) , false ) ; foreach ( DirectoryInfo subDir in dirs ) DirectoryCopy ( subDir . FullName , Path . Combine ( destDirName , subDir . Name ) , false ) ; }
Copies a directory to another location
Copies a directory to another location
sourceDirName
string
Source directory to copy
Source directory to copy
destDirName
string
None
firstPass
bool
Whether the current run of this method is the first one
Whether the current run of this method is the first one