Нужна помощь. Нужно получить все файлы и папки(а так же подпапки и подфайлы) скажем на диске C. Делаю так:
| Код | public static List<string> GetFilesRecursive(string b) //string b - path { // 1. // Store results in the file results list. List<string> result = new List<string>(); // 2. // Store a stack of our directories. Stack<string> stack = new Stack<string>(); // 3. // Add initial directory. stack.Push(b); // 4. // Continue while there are directories to process while (stack.Count > 0) { // A. // Get top directory string dir = stack.Pop(); try { // B // Add all files at this directory to the result List. result.AddRange(Directory.GetFiles(dir, "*.*")); // C // Add all directories at this directory. foreach (string dn in Directory.GetDirectories(dir)) { stack.Push(dn); } } catch { // D // Could not open the directory } } return result; }
|
Но на это проблема не заканчивается. Теперь надо записать их в XML, сохранив структуру. Туплю, не получается
|