using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace ListFoldersAndFiles
{
    public class Operation
    {
        public class FileFolderList
        {
            public string Name { get; set; }
            public string FullName { get; set; }
        }
        public static List<FileFolderList> GetAllFoldersAndFiles()
        {
            var list = new List<FileFolderList>();
            DriveInfo[] allDrives = DriveInfo.GetDrives();
            foreach (DriveInfo d in allDrives)
            {
                if (d.IsReady)
                {
                    var directories = new List<string>();
                    directories.Add(d.Name);

                    for (int i = 0; i < directories.Count; i++)
                    {
                        try
                        {
                            var files = Directory.GetFiles(directories[i],"*.*");
                            foreach(var file in files)
                            {
                                FileInfo info = new FileInfo(file);
                                list.Add(new FileFolderList
                                {
                                    Name = info.Name,
                                    FullName = info.FullName
                                });
                            }

                            var folders=Directory.GetDirectories(directories[i]);
                            directories.AddRange(folders);

                            foreach (var folder in folders)
                            {
                                FileInfo info = new FileInfo(folder);
                                list.Add(new FileFolderList
                                {
                                    Name = info.Name,
                                    FullName = info.FullName
                                });
                            }
                        }
                        catch
                        {

                        }
                    }

                }
            }
            return list;
        }
    }
}
