List<string> directorys = new List<string>(); List<string> filesinfo = new List<string>(); private void getlist(string path) { DirectoryInfo directory = new DirectoryInfo(path); FileSystemInfo[] filesArray = directory.GetFileSystemInfos(); foreach (var item in filesArray) { if (item.Attributes == FileAttributes.Directory) { directorys.Add(item.FullName); getlist(item.FullName); } else { filesinfo.Add(item.FullName); } } }