Beispiel #1
0
        public void TestGetFilesWithSearchWithNoResults()
        {
            var di    = new DirectoryInfo(uncDirectory);
            var files = di.GetFiles("giberish").ToArray();

            Assert.AreEqual(0, files.Length);
        }
Beispiel #2
0
        public void TestGetRecursiveFilesWithSubsetSearch()
        {
            var tempLongPathFilename = uncDirectory.Combine(Path.GetRandomFileName());

            tempLongPathFilename.CreateDirectory();

            try {
                Assert.IsTrue(tempLongPathFilename.Exists());
                var newEmptyFile1 = Util.CreateNewEmptyFile(tempLongPathFilename, "A-file");
                var newEmptyFile2 = Util.CreateNewEmptyFile(tempLongPathFilename, "B-file");

                try {
                    var randomFileName = newEmptyFile1.GetFileName();

                    var di    = new DirectoryInfo(uncDirectory);
                    var files = di.GetFiles("A*", SearchOption.AllDirectories).ToArray();
                    Assert.AreEqual(1, files.Length);
                    Assert.IsTrue(files.Any(f => f.Name == newEmptyFile1.GetFileName() && f.DirectoryName == newEmptyFile1.GetDirectoryName()));
                    Assert.IsFalse(files.Any(f => f.Name == newEmptyFile2.GetFileName() && f.DirectoryName == newEmptyFile2.GetDirectoryName()));
                    Assert.IsFalse(files.Any(f => f.Name == Filename.GetFileName() && f.DirectoryName == Filename.GetDirectoryName()));
                }
                finally {
                    Pri.LongPath.File.Delete(newEmptyFile1);
                    Pri.LongPath.File.Delete(newEmptyFile2);
                }
            }
            finally {
                const Boolean recursive = true;
                Pri.LongPath.Directory.Delete(tempLongPathFilename, recursive);
            }
        }
Beispiel #3
0
        public void TestGetFilesWithSearch()
        {
            var di    = new DirectoryInfo(uncDirectory);
            var files = di.GetFiles("*").ToArray();

            Assert.AreEqual(1, files.Length);
        }
Beispiel #4
0
        public void TestGetRecursiveFilesWithAllSearch()
        {
            var tempLongPathFilename = longPathDirectory.Combine(Path.GetRandomFileName());

            tempLongPathFilename.CreateDirectory();

            try {
                Assert.IsTrue(tempLongPathFilename.Exists());
                var newEmptyFile = Util.CreateNewEmptyFile(tempLongPathFilename);

                try {
                    var randomFileName = newEmptyFile.GetFileName();

                    var di    = new DirectoryInfo(longPathDirectory);
                    var files = di.GetFiles("*", SearchOption.AllDirectories).ToArray();
                    Assert.AreEqual(2, files.Length);
                    Assert.IsTrue(files.Any(f => f.Name == Filename));
                    Assert.IsTrue(files.Any(f => f.Name == randomFileName));
                }
                finally {
                    File.Delete(newEmptyFile);
                }
            }
            finally {
                const Boolean recursive = true;
                Directory.Delete(tempLongPathFilename, recursive);
            }
        }
Beispiel #5
0
        public void TestGetFiles()
        {
            var di    = new DirectoryInfo(uncDirectory);
            var files = di.GetFiles().ToArray();

            Assert.AreEqual(1, files.Length);
            Assert.IsTrue(files.Any(f => f.Name == Filename));
        }
 public IEnumerable <FileInfo> GetFileChangesSince(DateTime time, string directory)
 {
     Pri.LongPath.DirectoryInfo dInf = new Pri.LongPath.DirectoryInfo(directory);
     foreach (var fileInfo in dInf.GetFiles("*", System.IO.SearchOption.AllDirectories))
     {
         if (fileInfo.CreationTimeUtc >= time || fileInfo.LastWriteTimeUtc >= time)
         {
             yield return(fileInfo);
         }
     }
 }
 public IEnumerable<FileInfo> GetFileChangesSince(DateTime time, string directory)
 {
     Pri.LongPath.DirectoryInfo dInf = new Pri.LongPath.DirectoryInfo(directory);
     foreach (var fileInfo in dInf.GetFiles("*", System.IO.SearchOption.AllDirectories))
     {
         if (fileInfo.CreationTimeUtc >= time || fileInfo.LastWriteTimeUtc >= time)
         {
             yield return fileInfo;
         }
     }
 }
        private List<string> GetFileNames()
        {
            List<string> list = new List<string>();
            DirectoryInfo di = new DirectoryInfo(GetDirectory());
            if (di != null)
            {
                foreach (FileInfo fi in di.GetFiles())
                {
                    list.Add(fi.Name);
                }
            }

            return list;
        }