Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1003 B

  1. using System;
  2. using System.IO;
  3. namespace Microsoft.Fusion.ADF
  4. {
  5. public class MGFileCopier : IFileOperator
  6. {
  7. private string targetDir;
  8. public MGFileCopier(string targetDir)
  9. {
  10. this.targetDir = Path.GetFullPath(targetDir);
  11. }
  12. void IFileOperator.ProcessDirectory(string startDir, string relPathDir)
  13. {
  14. // create the directory
  15. string currAbsPath = Path.Combine(targetDir, relPathDir);
  16. if(!Directory.Exists(currAbsPath)) Directory.CreateDirectory(currAbsPath);
  17. }
  18. void IFileOperator.ProcessFile(string startDir, string relPathDir, string fileName)
  19. {
  20. // copy the file
  21. string relPath = Path.Combine(relPathDir, fileName);
  22. string sourceAbsPath = Path.Combine(startDir, relPath);
  23. string targetAbsPath = Path.Combine(targetDir, relPath);
  24. try
  25. {
  26. if(!File.Exists(targetAbsPath)) File.Copy(sourceAbsPath, targetAbsPath);
  27. }
  28. catch(Exception e)
  29. {
  30. Console.WriteLine("Exception " + e.ToString());
  31. }
  32. }
  33. }
  34. }