public void TestEnumerateFilesSearchWithNoResults() { var tempLongPathFilename = uncDirectory.Combine(Path.GetRandomFileName()); tempLongPathFilename.CreateDirectory(); try { var di = new DirectoryInfo(uncDirectory); Assert.AreEqual(0, di.EnumerateFiles("gibberish*").Count()); } finally { Pri.LongPath.Directory.Delete(tempLongPathFilename); } }
public void TestEnumerateFilesSearchWithResults() { var tempLongPathFilename = uncDirectory.Combine(Path.GetRandomFileName()); tempLongPathFilename.CreateDirectory(); try { var di = new DirectoryInfo(uncDirectory); var files = di.EnumerateFiles("*").ToArray(); Assert.AreEqual(1, files.Length); Assert.IsTrue(files.Any(f => f.Name == Filename)); } finally { Pri.LongPath.Directory.Delete(tempLongPathFilename); } }
public void TestEnumerateFilesWithSearchRecursiveAndOption() { var di = new DirectoryInfo(uncDirectory); var randomFileName = Path.GetRandomFileName(); var newDi = di.CreateSubdirectory(randomFileName); try { var fi = new FileInfo(newDi.FullName.Combine("filename")); using (fi.Create()) { } try { Assert.AreEqual(0, di.EnumerateFiles("gibberish", SearchOption.AllDirectories).Count()); } finally { fi.Delete(); } } finally { newDi.Delete(true); } }
public void TestEnumerateFiles() { var di = new DirectoryInfo(uncDirectory); var randomFileName = Path.GetRandomFileName(); var newDi = di.CreateSubdirectory(randomFileName); try { var fi = new FileInfo(newDi.FullName.Combine("filename")); using (fi.Create()) { } try { Assert.AreEqual(1, di.EnumerateFiles().Count()); } finally { fi.Delete(); } } finally { newDi.Delete(true); } }
public void TestEnumerateFilesWithSearchAndOption() { var di = new DirectoryInfo(longPathDirectory); var randomFileName = Path.GetRandomFileName(); var newDi = di.CreateSubdirectory(randomFileName); try { var fi = new FileInfo(newDi.FullName.Combine("filename")); using (fi.Create()) { } try { Assert.AreEqual(1, di.EnumerateFiles("*", SearchOption.TopDirectoryOnly).Count()); } finally { fi.Delete(); } } finally { newDi.Delete(true); } }