Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 4159

Copy folder contents from source directory to destination

$
0
0

I’m trying to write a script that will enable me to copy the contents from a source directory to a destination directory using a Boolean trigger.

This is what I have. Something I scraped of the internet.

I get an Error (CS1501): No overload for method ‘RunScript’ takes 2 arguments (line 95)

 private void RunScript(string sourcePath, string destinationPath, bool copy, ref object A)
  {
if (copy)
      if (!System.IO.Directory.Exists(sourcePath))
      {
        Print("Source directory does not exist.");
        return;
      }

    if (!System.IO.Directory.Exists(destinationPath))
      Directory.CreateDirectory(destinationPath);

    foreach (string file in Directory.GetFiles(sourcePath))
    {
      string fileName = Path.GetFileName(file);
      string destFile = Path.Combine(destinationPath, fileName);
      File.Copy(file, destFile, true);
    }

    foreach (string dir in Directory.GetDirectories(sourcePath))
    {
      string dirName = Path.GetFileName(dir);
      string destDir = Path.Combine(destinationPath, dirName);
      RunScript(dir, destDir);
    }

2 posts - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 4159

Latest Images

Trending Articles



Latest Images