I'm trying to copy one directory to another path and rename it...
I have a location like: C:\Backups
I have multiple locations such as (in a textbox):
C:\Users\xy\AppData\Local\....
C:\ProgramData\Test
C:\Tests\Test
I want now store all directory with all Files and Folders to the Backup Path..
Output Folder must looks like ->
C:\Backups\05.07.2018_17;00_FullFolderName
I Have this, but this isnt ideal...
this.CopyAll(new DirectoryInfo(@"C:\Test"), new DirectoryInfo(@"C:\Backups"));
private void CopyAll(DirectoryInfo oOriginal, DirectoryInfo oFinal)
{
foreach (DirectoryInfo oFolder in oOriginal.GetDirectories())
this.CopyAll(oFolder, oFinal.CreateSubdirectory(oFolder.Name));
foreach (FileInfo oFile in oOriginal.GetFiles())
oFile.CopyTo(oFinal.FullName + @"\" + oFile.Name, true);
}