0

I have excluded build folder from project. But when publish the project, I would like to copy the folder and its subfolders content to the root of the project. How can I include that into publish pubxml file?

Simon
  • 1,955
  • 5
  • 35
  • 49

1 Answers1

0

By using relative paths

private String newPath(Int32 noOfLevels, String SourcePath) 
{

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

and

//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);

found at Copy the entire contents of a directory in C#

It would be a duplicate question if not for the use of relative paths.

Community
  • 1
  • 1
online Thomas
  • 8,864
  • 6
  • 44
  • 85
  • Thanks, but I would like to do that when someone publish project, so I wan't to include code in pubxml file and not in cs. – Simon Oct 15 '15 at 14:39