Created
February 10, 2017 13:16
-
-
Save pedroinfo/ad17c8c986a827d94508fd0210d16c81 to your computer and use it in GitHub Desktop.
Copy Structure - Files and Folders
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.IO; | |
namespace CopiaEstrutura | |
{ | |
public class Program | |
{ | |
public static void Main(string[] args) | |
{ | |
string entrada = @"C:\ENTRADA"; | |
string saida = @"C:\SAIDA"; | |
var arquivos = Directory.EnumerateFiles(entrada, "*.xml", SearchOption.AllDirectories); | |
foreach (string diretorio in Directory.GetDirectories(entrada, "*.*", SearchOption.AllDirectories)) | |
{ | |
Directory.CreateDirectory(diretorio.Replace(entrada, saida)); | |
} | |
foreach (var arquivo in arquivos) | |
{ | |
File.Copy(arquivo, arquivo.Replace(entrada, saida), true); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment