public void CreateDirectortRecursively() { var directory = ApplicationPaths.RootDirectory; var directoryInfo = new DirectoryInfo(directory + "\\test\\test\\test\\test"); var mainDirectoryInfo = new DirectoryInfo(directory + "\\test\\"); if (mainDirectoryInfo.Exists) { mainDirectoryInfo.Delete(true); } Assert.IsFalse(Directory.Exists(mainDirectoryInfo.FullName)); directoryInfo.CreateRecursively(); Assert.IsTrue(Directory.Exists(mainDirectoryInfo.FullName)); Assert.IsTrue(Directory.Exists(directoryInfo.FullName)); }
public void TestCreateRecursive(string relativePath, char separator) { // Arrange var pathParts = relativePath.Split(separator); /* Dismantle and reassemble the path, because we want to be OS independent; * not everyone uses forward-slashes to separate paths. */ var reassembledRelativePath = Path.Combine(pathParts); var desiredPath = new DirectoryInfo(Path.Combine(_testRoot.FullName, reassembledRelativePath)); // Act desiredPath.CreateRecursively(); // Assert Assert.IsTrue(desiredPath.Exists, "Path has been created"); }
public void CopyDirectory() { var directory = ApplicationPaths.RootDirectory; var path1 = new DirectoryInfo(directory + @"\path\path"); path1.CreateRecursively(); CreateFoo(@"\path\path"); path1.CreateSubdirectory("path"); if (Directory.Exists(directory + @"\moved")) Directory.Delete(directory + @"\moved", true); path1.CopyTo(directory + @"\moved"); Assert.IsTrue(File.Exists(directory + @"\moved\foo.bar")); Assert.IsTrue(Directory.Exists(directory + @"\moved\path")); }