Esempio n. 1
0
        public override void visitChildren(FileVisitor fileVisitor, DirectoryVisitor directoryVisitor, VisitFailed visitFailed)
        {
            try
            {
                IReadOnlyList <IStorageItem> storageItems = getStorageFolder().GetItemsAsync().DoSynchronously();

                foreach (IStorageItem storageItem in storageItems)
                {
                    StorageItemPathAttributes pathAttributes = new StorageItemPathAttributes(storageItem);

                    if (storageItem is IStorageFolder)
                    {
                        if (directoryVisitor != null)
                        {
                            directoryVisitor(new StorageFolderDirectory(this, (StorageFolder)storageItem));
                        }
                    }
                    else if (storageItem is IStorageFile)
                    {
                        if (fileVisitor != null)
                        {
                            fileVisitor(new StorageFileFile(this, (StorageFile)storageItem));
                        }
                    }
                    else
                    {
                        throw new Exception("Unknown type of StorageItem: " + storageItem);
                    }
                }
            }
            catch (System.IO.IOException e)
            {
                throw DotNetIOUtils.jSimpleExceptionFromDotNetIOException(e);
            }
        }
        public override void visitChildren(DirectoryVisitor visitor)
        {
            try
            {
                IReadOnlyList<IStorageItem> storageItems = StorageFolder.GetItemsAsync().DoSynchronously();

                foreach (IStorageItem storageItem in storageItems)
                {
                    StorageItemPathAttributes pathAttributes = new StorageItemPathAttributes(storageItem);

                    if (storageItem is IStorageFolder)
                        visitor.visit(new StorageFolderDirectory(this, (StorageFolder)storageItem));
                    else if (storageItem is IStorageFile)
                        visitor.visit(new StorageFileFile(this, (StorageFile)storageItem));
                    else throw new Exception("Unknown type of StorageItem: " + storageItem);
                }
            }
            catch (System.IO.IOException e)
            {
                throw DotNetIOUtils.jSimpleExceptionFromDotNetIOException(e);
            }
        }