Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8236649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T19:12:04+00:00 2026-06-07T19:12:04+00:00

I am trying to create an XML file containing Folder and files description. I

  • 0

I am trying to create an XML file containing Folder and files description.
I browse the folder content with a recursive method and I would like to append datas at each call.

Here is the code I use :

        DataSet ds = new DataSet("Folders");
        ds.Tables.Add(Folder);
        ds.Tables.Add(Files);
        ds.WriteXml(AppDomain.CurrentDomain.BaseDirectory + "\\FolderList.xml");

Could you please tell me how to proceed to add at each function call datas at the bottom of the xml file ?

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T19:12:05+00:00Added an answer on June 7, 2026 at 7:12 pm
    string rootPath = @"......";
    XElement xRoot = new XElement("Root",new XAttribute("Path",rootPath));
    RecurseDirs(rootPath, xRoot);
    var xmlString = xRoot.ToString();
    
    
    
    void RecurseDirs(string root, XElement xRoot)
    {
        foreach (var dir in Directory.EnumerateDirectories(root))
        {
            XElement xdir = new XElement("Directory",
                                            new XAttribute("Name",Path.GetFileName(dir)),
                                            new XAttribute("CreationTime",Directory.GetCreationTime(dir)));
            xRoot.Add(xdir);
            RecurseDirs(dir,xdir);
        }
    
        foreach (var dir in Directory.EnumerateFiles(root))
        {
            XElement xfile = new XElement("File", 
                new XAttribute("Name", Path.GetFileName(dir)),
                new XAttribute("CreationTime", File.GetCreationTime(dir)));
            xRoot.Add(xfile);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create an xml file like below in .NET. Actually I
I'm trying to create a new xml file with parts from other xml files.
I would like to create an XML file like this: <?xml version=1.0 encoding=UTF-8?> <text>
I am trying to dynamically create an XML file using php like this: header
I am trying to create an XML file, but the XML file needs to
I am trying to create an XML file to conform to someones XSD this
I'm trying to create an xml entry that looks like this using python and
I'm trying to create an element in an XML where the basic content is
I have an XML file containing seed data that I'm trying to load into
I am trying to create a Xml schema for a xml file that looks

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.