public void CopyDirectory() { try { if (!HasFolderPermission || !HasFilePermission) { return; } Assert.IsFalse(IoDir.DirectoryExists(TestFolder + "//"), "Invalid directory path"); Assert.IsTrue(IoDir.CreateDirectory(TestFolder + "//"), "Error creating directory"); Assert.IsTrue(IoDir.DirectoryExists(TestFolder + "//"), "Error creating directory"); for (var d = 0; d < 5; d++) { if (d == 0) { for (var i = 0; i < 20; i++) { IoFiles.CreateFile(TestFolder + "//" + i + ".txt", i.ToString(CultureInfo.InvariantCulture)); } } IoDir.CreateDirectory(TestFolder + "//" + d + "//"); for (var i = 0; i < 20; i++) { IoFiles.CreateFile(TestFolder + "//" + d + "//" + i + ".txt", i.ToString(CultureInfo.InvariantCulture)); } } Assert.IsFalse(IoDir.DirectoryExists(TestFolderCopy + "//"), "Invalid directory path"); IoDir.CopyDirectory(TestFolder, TestFolderCopy); Assert.IsTrue(IoDir.DirectoryExists(TestFolderCopy + "//"), "Error creating directory"); var mainFilesCount = IoFiles.GetCountOfFilesInDirectoryAndSubdirectories(TestFolder + "//"); var copyFilesCount = IoFiles.GetCountOfFilesInDirectoryAndSubdirectories(TestFolderCopy + "//"); Console.WriteLine("Main folder files count: {0}", mainFilesCount); Console.WriteLine("Copy folder files count: {0}", copyFilesCount); Assert.IsTrue(mainFilesCount == copyFilesCount, "Error coping files"); } finally { if (HasFolderPermission) { IoDir.DeleteDirectory(TestFolder + "//"); IoDir.DeleteDirectory(TestFolderCopy + "//"); } } }