{"id":3113,"date":"2004-07-02T18:36:00","date_gmt":"2004-07-02T08:36:00","guid":{"rendered":"http:\/\/new.radio-active.net.au\/web3\/programming-notes-directory-to-xml-recursive\/"},"modified":"2014-10-10T13:14:12","modified_gmt":"2014-10-10T02:14:12","slug":"programming-notes-directory-to-xml-recursive","status":"publish","type":"post","link":"http:\/\/www.radio-active.net.au\/web3\/3113","title":{"rendered":"Programming Notes &#8211; Directory to XML recursive"},"content":{"rendered":"<h2>Converting a Directory Structure to XML in VB.NET<\/h2>\n<p>There is an article on <a href=\"http:\/\/builder.com.com\/5100-6373-1044638.html\">Builder.Com.Com<\/a> showing how to convert a directory structure to XML. Unfortunately it is not a recursive function, but how hard can that be? OK, well I know how hard it can be, but it should not be too hard. We will see. <\/p>\n<p>There were some issues, but I got it to work. It is a start at least. <\/p>\n<p><tt>Public Function DirectoryStart(ByVal path As String) As String<br \/>\n<br \/>        Dim sw As New StringWriter<br \/>\n<br \/>        Dim xmlwriter As New XmlTextWriter(sw)<br \/>\n<br \/>        xmlwriter.WriteStartDocument()<br \/>\n<br \/>        DirectoryRecurse(path, xmlwriter)<br \/>\n<br \/>        xmlwriter.WriteEndDocument()<br \/>\n<br \/>        xmlwriter.Close()<br \/>\n<br \/>        Return sw.ToString<br \/>\n<br \/>    End Function<\/p>\n<p>    Public Sub DirectoryRecurse(ByVal path As String, ByVal xmlw As XmlWriter)<br \/>\n<br \/>        Dim filename As String ' , path As String<br \/>\n<br \/>        Dim dir As New DirectoryInfo(path)<br \/>\n<br \/>        Dim xtw As XmlTextWriter<br \/>\n<br \/>        With xmlw<br \/>\n<br \/>            .WriteComment(\" Content of the \" & Chr(34) & path & Chr(34) & \" folder \")<br \/>\n<br \/>            .WriteStartElement(\"folders\")<br \/>\n<br \/>            .WriteAttributeString(\"path\", path)<br \/>\n<br \/>            .WriteAttributeString(\"count\", dir.GetDirectories().Length.ToString())<br \/>\n<br \/>            For Each d As DirectoryInfo In dir.GetDirectories()<br \/>\n<br \/>                .WriteStartElement(\"folder\")<br \/>\n<br \/>                .WriteAttributeString(\"name\", d.Name)<br \/>\n<br \/>                .WriteAttributeString(\"accessed\", d.LastAccessTime.ToString())<br \/>\n<br \/>                .WriteString(\"Content of \" + d.Name)<br \/>\n<br \/>                .WriteEndElement()<br \/>\n<br \/>                DirectoryRecurse(d.FullName, xmlw)<br \/>\n<br \/>            Next<br \/>\n<br \/>            .WriteEndElement()<br \/>\n<br \/>        End With<br \/>\n<br \/>    End Sub<br \/>\n<br \/><\/tt><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Converting a Directory Structure to XML in VB.NET There is an article on Builder.Com.Com showing how to convert a directory structure to XML. Unfortunately it is not a recursive function, but how hard can that be? OK, well I know &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"more-link\" href=\"http:\/\/www.radio-active.net.au\/web3\/3113\"> <span class=\"screen-reader-text\">Programming Notes &#8211; Directory to XML recursive<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[],"tags":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5cfmK-Od","_links":{"self":[{"href":"http:\/\/www.radio-active.net.au\/web3\/wp-json\/wp\/v2\/posts\/3113"}],"collection":[{"href":"http:\/\/www.radio-active.net.au\/web3\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.radio-active.net.au\/web3\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.radio-active.net.au\/web3\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"http:\/\/www.radio-active.net.au\/web3\/wp-json\/wp\/v2\/comments?post=3113"}],"version-history":[{"count":0,"href":"http:\/\/www.radio-active.net.au\/web3\/wp-json\/wp\/v2\/posts\/3113\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.radio-active.net.au\/web3\/wp-json\/wp\/v2\/media?parent=3113"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.radio-active.net.au\/web3\/wp-json\/wp\/v2\/categories?post=3113"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.radio-active.net.au\/web3\/wp-json\/wp\/v2\/tags?post=3113"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}