Archives

Archives / 2005 / June
  • [Books][.NET 2.0] Recommended .NET 2.0 books?

    I need your help. I'm going to the PDC and I need to read up on various .NET 2.0 stuff before going there, to get most out of it. ASP.NET and Web Services/Interop is my main focus, so if someone out there knows of a really good book to read, please comment. I got a few books that I've read already, like the "A First Look at ASP.NET v2.0" by Homer/Sussman/Howard, but I'm sure there are more updated ones.

    Thanks!

  • [PDC] Booked!

    I did my registration to the PDC today, it will be so interesting and fun going there. There will be so many cool tracks and session, it'll be a tough time figuring out which ones to attend to. When I get back I'll have to do some "awareness sessions" for my mates at work, but I don't mind at all doing that.

    It seems there will be lots of Swedish people going over the pond this time, so LA watch out :) The last time I was at the PDC I didn't get any chance to see anything of LA except for the Convention Center and the hotel. This time I'll try to go there a day or so ahead. 

  • Xml from a directory structure

    I needed to generate an XML document that showed all directories and html files in a certain folder and the folders below that. This is what I quickly wipped up:

    using System;

    using System.IO;

    using System.Xml;

     

    namespace MenuBuilder

    {

               /// <summary>

               /// Summary description for MenuBuilder.

               /// </summary>

               public class MenuBuilder

               {

                          public static void Main(string[] args)

                          {

                                     Console.WriteLine("Starting...");

     

                                     XmlDocument doc = new XmlDocument();

                                     doc.LoadXml("<directory>" +

                                                "</directory>");

     

                                     //recurse through directories and return XmlNodes

                                     XmlElement elem = GetData(@"c:\temp", doc);

                                     doc.DocumentElement.AppendChild(elem);

     

                                     doc.Save(@"c:\temp\dir.xml");

                          }

     

                          private static XmlElement GetData(string dirName, XmlDocument doc)

                          {

                                     //create a new node for this directory

                                     XmlElement elem = doc.CreateElement("dir");

                                     DirectoryInfo di = new DirectoryInfo(dirName);

                                     elem.SetAttribute("name",di.Name);

     

                                     foreach (DirectoryInfo dinf in di.GetDirectories())

                                     {

                                                //Recursively call the directory with all underlying dirs and files

                                                XmlElement elemDir = GetData(dirName + "\\" + dinf.Name, doc);

                                                elem.AppendChild(elemDir);

                                     }

     

                                     //Append the files in this directory to the current xml node

                                     foreach (FileInfo finf in di.GetFiles("*.htm*"))

                                     {

                                                XmlElement elemDir = doc.CreateElement("file");

                                                elemDir.SetAttribute("name",finf.Name);

                                                elem.AppendChild(elemDir);

                                     }

     

                                     return elem;

                          }

               }

    }