here you are. try it and let me know if you need anything else:
private void Form1_Load(object sender, EventArgs e)
{
var sb = new StringBuilder();
DirSearch(@"C:\Users\vitor\Documents\Visual Studio 2012\Projects\WindowsFormsApplication2", sb);
File.WriteAllText(@"C:\Users\vitor\Desktop\output.txt", sb.ToString());
}
static string ultimaLinha = "";
static void DirSearch(string sDir, StringBuilder sb)
{
try
{
foreach (string d in Directory.GetDirectories(sDir))
{
string u = d.Substring(0, d.LastIndexOf("\\"));
if (u != ultimaLinha)
{
foreach (string file in Directory.GetFiles(d))
sb.AppendLine(file);
}
ultimaLinha = u;
DirSearch(d, sb);
}
}
catch (System.Exception excpt)
{
Console.WriteLine(excpt.Message);
}
}