Ejemplo n.º 1
0
        public void TestGetDirectoriesWithSearchWithNoResults()
        {
            var randomFileName       = Pri.LongPath.Path.GetRandomFileName();
            var tempLongPathFilename = longPathDirectory.Combine(randomFileName);

            tempLongPathFilename.CreateDirectory();

            try {
                var dirs = Directory.GetDirectories(longPathDirectory, "gibberish").ToArray();
                Assert.AreEqual(0, dirs.Length);
                Assert.IsFalse(dirs.Contains(tempLongPathFilename));
            }
            finally {
                Directory.Delete(tempLongPathFilename);
            }
        }
Ejemplo n.º 2
0
        public void TestGetDirectoriesWithSubsetSearch()
        {
            var tempLongPathFilename = longPathDirectory.Combine("TestGetDirectoriesWithSubsetSearch");

            tempLongPathFilename.CreateDirectory();
            var tempLongPathFilename2 = longPathDirectory.Combine("ATestGetDirectoriesWithSubsetSearch");

            tempLongPathFilename2.CreateDirectory();

            try {
                Assert.AreEqual(1, Directory.GetDirectories(longPathDirectory, "A*").Count());
            }
            finally {
                Directory.Delete(tempLongPathFilename);
                Directory.Delete(tempLongPathFilename2);
            }
        }
Ejemplo n.º 3
0
        static DirectoryNode GenerateNodeTree(string dir, DirectoryNode parent)
        {
            Globals.curDir = dir;
            DirectoryNode newNode = new DirectoryNode(parent, dir, false);

            try
            {
                string[]             files    = Directory.GetFiles(dir, "*.*");
                long                 size     = 0;
                List <DirectoryNode> children = new List <DirectoryNode>();
                foreach (string name in files)
                {
                    FileInfo info = new FileInfo(name);
                    size += info.Length;
                    DirectoryNode tempFileNode = new DirectoryNode(newNode, name, true)
                    {
                        size = info.Length
                    };
                    nodeTree.Add(tempFileNode);
                    children.Add(tempFileNode);
                }
                string[] c = Directory.GetDirectories(dir, "*.*");
                Globals.curAllDir += c.Length;
                foreach (string name in c)
                {
                    DirectoryNode tempNode = GenerateNodeTree(name, newNode);
                    size += tempNode.size;
                    children.Add(tempNode);
                }
                newNode.size     = size;
                newNode.children = children;
                nodeTree.Add(newNode);
                Globals.curDoneDir++;
            }
            catch
            {
                newNode.size   = 0;
                newNode.locked = true;
            }
            return(newNode);
        }
Ejemplo n.º 4
0
 public void TestGetDirectories() => Assert.AreEqual(0, Directory.GetDirectories(longPathDirectory).Count());