private void AlphaFS_Directory_EnumerateFileSystemEntryInfos_FolderWithSpaceAsName(bool isNetwork)
        {
            using (var tempRoot = new TemporaryDirectory(isNetwork))
            {
                const int maxFso      = 5;
                const int expectedFso = 12;

                var folder = tempRoot.CreateRandomizedAttributesTree(maxFso);

                Console.WriteLine("Input Directory Path: [{0}]\n", folder.FullName);


                for (var i = 0; i < maxFso; i++)
                {
                    var spaceFolder = folder.FullName + @"\" + new string(' ', i + 1) + @"\" + "no_void";

                    Alphaleonis.Win32.Filesystem.Directory.CreateDirectory(spaceFolder, Alphaleonis.Win32.Filesystem.PathFormat.LongFullPath);
                }


                var countNamedFolders = 0;
                var countSpaceFolders = 0;

                foreach (var fsei in Alphaleonis.Win32.Filesystem.Directory.EnumerateFileSystemEntryInfos <Alphaleonis.Win32.Filesystem.FileSystemInfo>(folder.FullName))
                {
                    var path = fsei.FullName;

                    Console.WriteLine("\tDirectory: [{0}]", path);


                    if (char.IsWhiteSpace(path[path.Length - 1]))
                    {
                        countSpaceFolders++;
                        Assert.IsTrue(fsei.Exists);
                    }

                    else
                    {
                        countNamedFolders++;
                    }
                }


                Assert.AreEqual(expectedFso, countNamedFolders + countSpaceFolders);
            }

            Console.WriteLine();
        }
Exemple #2
0
        private void AlphaFS_Directory_EnumerateFileIdBothDirectoryInfo(bool isNetwork)
        {
            using (var tempRoot = new TemporaryDirectory(isNetwork))
            {
                var folder = tempRoot.CreateRandomizedAttributesTree(5);

                Console.WriteLine("Input Directory Path: [{0}]\n", folder.FullName);

                var sysIOCollection = System.IO.Directory.EnumerateFileSystemEntries(folder.FullName).Select(System.IO.Path.GetFileName).ToArray();

                var alphaFSCollection = Alphaleonis.Win32.Filesystem.Directory.EnumerateFileIdBothDirectoryInfo(folder.FullName).ToArray();

                Console.WriteLine("\tSystem.IO items enumerated: {0:N0}", sysIOCollection.Length);
                Console.WriteLine("\tAlphaFS   items enumerated: {0:N0}", alphaFSCollection.Length);


                // Since System.IO does not have a EnumerateFileIdBothDirectoryInfo method, we can only compare the collection of fso names.

                CollectionAssert.AreEquivalent(sysIOCollection, alphaFSCollection.Select(item => item.FileName).ToArray());
            }

            Console.WriteLine();
        }