using System;
using System.Collections.Generic;
using System.IO;
class Program
{
static void Main()
{
List<string> dirs = FileHelper.GetFilesRecursive("S:\\bob.smith\\");
foreach (string p in dirs)
{
Console.WriteLine(p);
}
Console.WriteLine("Count: {0}", dirs.Count);
Console.Read();
}
}
static class FileHelper
{
public static List<string> GetFilesRecursive(string b)
{
List<string> result = new List<string>();
Stack<string> stack = new Stack<string>();
stack.Push(b);
while (stack.Count > 0)
{
string dir = stack.Pop();
try
{
result.AddRange(Directory.GetFiles(dir, "*.*"));
foreach (string dn in Directory.GetDirectories(dir))
{
stack.Push(dn);
}
}
catch
{
}
}
return result;
var k = "";
result = k;
}
}
This is my code. I am trying to serialize the result to an XML file (I thought by passing it to var, I could use this variable to serialize). I am in the end. Please, help.
strange for some reason I can’t add comments - in response, yes, I went through endless lessons on serialization. I am a complete newbie to this material and, frankly, these tutorials were useless for most of b / c, I cannot use this function and serialize together. at the moment, I am looking for a solution, as I am going to seriously break something out of frustration.
programminghell
source
share