Копировать внешнюю папку при публикации проекта

Я исключил сборочную папку из проекта. Но при публикации проекта я бы хотел скопировать содержимое папки и подпапок в корень проекта. Как я могу включить это в файл pubxml публикации?

1 ответ

Используя относительные пути

private String newPath(Int32 noOfLevels, String SourcePath) 
{

   String path = "";
   for(int i=0; i< noOfLevels; i++) {
     path+= "..\";
   }
   path += SourcePath;
   return path;
}

а также

//Now Create all of the directories
foreach (string dirPath in Directory.GetDirectories(SourcePath, "*", 
    SearchOption.AllDirectories))
    Directory.CreateDirectory(dirPath.Replace(SourcePath, DestinationPath));

//Copy all the files & Replaces any files with the same name
foreach (string newPath in Directory.GetFiles(SourcePath, "*.*", 
    SearchOption.AllDirectories))
    File.Copy(newPath, newPath.Replace(SourcePath, DestinationPath), true);

найти в Копировать все содержимое каталога в C#

Это был бы дублирующий вопрос, если бы не использование относительных путей.

Другие вопросы по тегам