diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-11-28 13:16:26 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-11-28 13:16:26 +0200 |
| commit | e0ef31c25e7f9b21ee3bae53167f2c7851b94748 (patch) | |
| tree | a71ab2e285897d60371cba964094d309123efbaa /Software/Visual_Studio/Tango.Core | |
| parent | 8276e5eb7c56b58ed86f611ca5bd9b1dc56b25b9 (diff) | |
| download | Tango-e0ef31c25e7f9b21ee3bae53167f2c7851b94748.tar.gz Tango-e0ef31c25e7f9b21ee3bae53167f2c7851b94748.zip | |
Completed PPC Backup/Restore !!!
Diffstat (limited to 'Software/Visual_Studio/Tango.Core')
| -rw-r--r-- | Software/Visual_Studio/Tango.Core/Helpers/PathHelper.cs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/Software/Visual_Studio/Tango.Core/Helpers/PathHelper.cs b/Software/Visual_Studio/Tango.Core/Helpers/PathHelper.cs index ee2e3e132..11716ccda 100644 --- a/Software/Visual_Studio/Tango.Core/Helpers/PathHelper.cs +++ b/Software/Visual_Studio/Tango.Core/Helpers/PathHelper.cs @@ -72,7 +72,12 @@ namespace Tango.Core.Helpers /// <param name="copySubDirs">if set to <c>true</c> will copy sub directories.</param> /// <exception cref="DirectoryNotFoundException">Source directory does not exist or could not be found: " /// + sourcePath</exception> - public static void CopyDirectory(string sourcePath, string destinationPath, bool copySubDirs) + public static void CopyDirectory(string sourcePath, string destinationPath, bool copySubDirs, Action<int, int> progress = null) + { + CopyDirectoryInternal(sourcePath, destinationPath, copySubDirs, progress, Directory.GetFiles(sourcePath, "*.*", SearchOption.AllDirectories).Length, 0); + } + + private static void CopyDirectoryInternal(string sourcePath, string destinationPath, bool copySubDirs, Action<int, int> progress, int total, int current) { // Get the subdirectories for the specified directory. DirectoryInfo dir = new DirectoryInfo(sourcePath); @@ -97,6 +102,8 @@ namespace Tango.Core.Helpers { string temppath = Path.Combine(destinationPath, file.Name); file.CopyTo(temppath, false); + current++; + progress?.Invoke(current, total); } // If copying subdirectories, copy them and their contents to new location. @@ -105,7 +112,7 @@ namespace Tango.Core.Helpers foreach (DirectoryInfo subdir in dirs) { string temppath = Path.Combine(destinationPath, subdir.Name); - CopyDirectory(subdir.FullName, temppath, copySubDirs); + CopyDirectoryInternal(subdir.FullName, temppath, copySubDirs, progress, total, current); } } } |
