public void TestEnumerateRecursiveFileSystemEntriesWithSearch() { var tempLongPathFilename = longPathDirectory.Combine(Pri.LongPath.Path.GetRandomFileName()); tempLongPathFilename.CreateDirectory(); try { Assert.IsTrue(tempLongPathFilename.Exists()); var randomFileName = Util.CreateNewEmptyFile(tempLongPathFilename); var entries = Directory.EnumerateFileSystemEntries(longPathDirectory, "*", SearchOption.AllDirectories).ToArray(); Assert.AreEqual(3, entries.Length); Assert.IsTrue(entries.Contains(longPathFilename)); Assert.IsTrue(entries.Contains(randomFileName)); } finally { const Boolean recursive = true; Directory.Delete(tempLongPathFilename, recursive); } }
public void TearDown() { try { if (File.Exists(longPathFilename)) { File.Delete(longPathFilename); } } catch (Exception e) { Trace.WriteLine("Exception {0} deleting \"longPathFilename\"", e.ToString()); throw; } finally { if (longPathRoot.Exists()) { Directory.Delete(longPathRoot, true); } } }
public void TestRecursiveEnumerateDirectoriesWithMultipleSubsetSearch() { var randomFileName = "TestRecursiveEnumerateDirectoriesWithMultipleSubsetSearch"; var tempLongPathFilename = longPathDirectory.Combine(randomFileName); tempLongPathFilename.CreateDirectory(); randomFileName = "ATestRecursiveEnumerateDirectoriesWithMultipleSubsetSearch"; var tempLongPathFilename2 = longPathDirectory.Combine(randomFileName); tempLongPathFilename2.CreateDirectory(); try { var dirs = Directory.EnumerateDirectories(longPathDirectory, "T*", SearchOption.AllDirectories).ToArray(); Assert.AreEqual(1, dirs.Length); Assert.IsTrue(dirs.Contains(tempLongPathFilename)); Assert.IsFalse(dirs.Contains(tempLongPathFilename2)); } finally { Directory.Delete(tempLongPathFilename); Directory.Delete(tempLongPathFilename2); } }
public void TestGetRecursiveFilesWithSubsetSearch() { var tempLongPathFilename = longPathDirectory.Combine(Pri.LongPath.Path.GetRandomFileName()); tempLongPathFilename.CreateDirectory(); try { Assert.IsTrue(tempLongPathFilename.Exists()); var randomFileName = Util.CreateNewEmptyFile(tempLongPathFilename); var searchPattern = randomFileName.GetFileName().Substring(0, 3) + "*" + randomFileName.GetExtension(); var files = Directory.GetFiles(longPathDirectory, searchPattern, SearchOption.AllDirectories).ToArray(); Assert.AreEqual(1, files.Length); Assert.IsFalse(files.Contains(longPathFilename)); Assert.IsTrue(files.Contains(randomFileName)); } finally { const Boolean recursive = true; Directory.Delete(tempLongPathFilename, recursive); } }
public void TestGetDirectoriesWithMultipleResultSubsetSearch() { const String randomFileName = "TestGetDirectoriesWithMultipleResultSubsetSearch"; const String randomFileName2 = "ATestGetDirectoriesWithMultipleResultSubsetSearch"; var tempLongPathFilename = longPathDirectory.Combine(randomFileName); var tempLongPathFilename2 = longPathDirectory.Combine(randomFileName2); tempLongPathFilename.CreateDirectory(); tempLongPathFilename2.CreateDirectory(); try { var di = new DirectoryInfo(longPathDirectory); var dirs = di.GetDirectories("A*").ToArray(); Assert.AreEqual(1, dirs.Length); Assert.IsTrue(dirs.Any(f => f.Name == randomFileName2)); Assert.IsFalse(dirs.Any(f => f.Name == randomFileName)); } finally { Directory.Delete(tempLongPathFilename); Directory.Delete(tempLongPathFilename2); } }
public void TestMove() { var tempLongPathFilename1 = longPathDirectory.Combine(Pri.LongPath.Path.GetRandomFileName()); tempLongPathFilename1.CreateDirectory(); Assert.IsTrue(tempLongPathFilename1.GetFullPath().Exists()); var tempLongPathFilename2 = longPathDirectory.Combine(Pri.LongPath.Path.GetRandomFileName()); tempLongPathFilename2.CreateDirectory(); Assert.IsTrue(tempLongPathFilename2.GetFullPath().Exists()); var destinationPath = tempLongPathFilename1.Combine(tempLongPathFilename2.GetFileName()).GetFullPath(); Directory.Move(tempLongPathFilename2, destinationPath); Assert.IsTrue(tempLongPathFilename1.GetFullPath().Exists()); Assert.IsFalse(tempLongPathFilename2.GetFullPath().Exists()); Assert.IsTrue(destinationPath.Exists()); const Boolean recursive = true; Directory.Delete(tempLongPathFilename1, recursive); Directory.Delete(tempLongPathFilename2, recursive); }
public void TestMoveTo() { var randomFileName = Path.GetRandomFileName(); var randomFileName2 = Path.GetRandomFileName(); var tempLongPathFilename = longPathDirectory.Combine(randomFileName); var tempLongPathFilename2 = longPathDirectory.Combine(randomFileName2); tempLongPathFilename.CreateDirectory(); try { var di = new DirectoryInfo(tempLongPathFilename); di.MoveTo(tempLongPathFilename2); di = new DirectoryInfo(longPathDirectory); var dirs = di.EnumerateDirectories("*", SearchOption.TopDirectoryOnly).ToArray(); Assert.AreEqual(1, dirs.Length); Assert.IsTrue(dirs.Any(f => f.Name == randomFileName2)); Assert.IsFalse(dirs.Any(f => f.Name == randomFileName)); } finally { Directory.Delete(tempLongPathFilename2); } Assert.IsFalse(tempLongPathFilename.Exists()); }
public void TearDown() { Directory.Delete(longPathRoot, true); Debug.Assert(!longPathDirectory.Exists()); }