Click here to Skip to main content
15,886,026 members
Please Sign up or sign in to vote.
1.33/5 (2 votes)
See more:
Hi,

I am trying to create a VB.NET application that among other things lists the contents of a directory and sub directories and saves the output into an XML file.

The reason i would like an XML file is so i can save other information about each file: Size, Modification date and Path.

I got as far as recursively querying the directory and creating an XML of paths as strings. But when I created a structure for the modification date and size i got a bit lost.

Any help and or advice would be appreciated.

Thanks in advance Chris.
Posted
Updated 7-Feb-14 5:09am
v2
Comments
Sergey Alexandrovich Kryukov 7-Feb-14 11:10am    
What have you tried so far?
"...a bit lost" is not informative at all. Why "XML of paths as strings"?..
—SA
chris pavey 7-Feb-14 11:27am    
Maybe i need to explain what I'm trying to create and see if anyone has any better ideas to achieve what I'm trying to achieve.

I have an ftp server and a client. The client interrogatives the server and recursively searches the directories on the server. It creates a collection of files stored on the server. it then compares this to its local collection of files. And downloads files it doesn't have and newer versions of files.

The issue is this is slow and quite insecure as it sends a lot of commands over the internet for all this listing.

My solution is to create a XML on the server and one on the local machine. Then the client would only need to download that XML and then compare that to their local XML. this would instantly give you the list of new files to download.

At first i was going to make a .txt file but i thought an XML would suit this purpose better because of the additional information I wanted to include.
Sergey Alexandrovich Kryukov 7-Feb-14 13:35pm    
I answered on how to do it. Did you see my answer? First of all, don't generate any XML text manually.
—SA

Please see my comment to the question.

As .NET FCL offers different ways to write and parse XML, you need to choose one you prefer and go ahead, not trying to manually compose XML strings:
  1. Use System.Xml.XmlDocument class. It implements DOM interface; this way is the easiest and good enough if the size if the document is not too big.
    See http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^].
  2. Use the classes System.Xml.XmlTextWriter and System.Xml.XmlTextReader; this is the fastest way of reading, especially is you need to skip some data.
    See http://msdn.microsoft.com/en-us/library/system.xml.xmlwriter.aspx[^], http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.aspx[^].
  3. Use the class System.Xml.Linq.XDocument; this is the most adequate way similar to that of XmlDocument, supporting LINQ to XML Programming.
    See http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^], http://msdn.microsoft.com/en-us/library/bb387063.aspx[^].


—SA
 
Share this answer
 
Maybe i need to explain what I'm trying to create and see if anyone has any better ideas to achieve what I'm trying to achieve.

I have an ftp server and a client. The client interrogatives the server and recursively searches the directories on the server. It creates a collection of files stored on the server. it then compares this to its local collection of files. And downloads files it doesn't have and newer versions of files.

The issue is this is slow and quite insecure as it sends a lot of commands over the internet for all this listing.

My solution is to create a XML on the server and one on the local machine. Then the client would only need to download that XML and then compare that to their local XML. this would instantly give you the list of new files to download.

At first i was going to make a .txt file but i thought an XML would suit this purpose better because of the additional information I wanted to include.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900