using System;
using System.Linq;
using System.Xml.Linq;
using System.IO;

namespace TreeXml
{
    class Program
    {
        static void Main(string[] args)
        {
            foreach (string path in args) {
                if (Directory.Exists(path)) {
                    DirectoryInfo rootDir = new DirectoryInfo(path);
                    XElement xe = new XElement("Root",
                        new XAttribute("Path", path));

                    try {
                        MakeXML(path, ref xe);
                        xe.Save(string.Format(@".\\{0}.xml", rootDir.Name));
                    }
                    catch (Exception e) {
                        Console.WriteLine(e.Message);
                        Console.ReadKey();
                    }
                }
                else{
                    Console.WriteLine("[ {0} ]\r\n존재하지 않는 디렉토리입니다.", path);
                    Console.ReadKey();
                }
            }
        }

        private static void MakeXML(string path, ref XElement xeNode)
        {
            DirectoryInfo dirInfo = new DirectoryInfo(path);
            DirectoryInfo[] subDirList = dirInfo.GetDirectories();

            if (subDirList.Count() > 0){
                foreach (DirectoryInfo subDir in subDirList){
                    XElement xe = new XElement("Directroy",
                        new XAttribute("Name", subDir.Name));
                    xeNode.Add(xe);
                    MakeXML(subDir.FullName, ref xe);
                }
            }

            foreach (FileInfo file in dirInfo.GetFiles()){
                xeNode.Add(new XElement("File",
                            new XAttribute("Path", file.FullName),
                            new XElement("Name", file.Name),
                            new XElement("Extension", file.Extension),
                            new XElement("Size", file.Length),
                            new XElement("Attribute", file.Attributes),
                            new XElement("CreationTime", file.CreationTime),
                            new XElement("LastAccessTime", file.LastAccessTime),
                            new XElement("LastAccessTime", file.LastWriteTime)
                    ));
            }
        }
    }
}

드래그해서 놓기여