コード例 #1
0
        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);
            }
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
        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);
            }
        }
コード例 #4
0
        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);
            }
        }
コード例 #5
0
        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);
            }
        }