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

  • SEARCH
  • Home
  • 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 7809667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:30:52+00:00 2026-06-02T03:30:52+00:00

the application idea is simple , the application is given a path , and

  • 0

the application idea is simple , the application is given a path , and application writes each file`s path into XML , the problem i am facing is the file name can have invalid character and that makes the application stops working , here is the code i use to parse file information into XML :

    // the collecting details method
    private void Get_Properties(string path)
    {
        // Load the XML File
        XmlDocument xml = new XmlDocument();
        xml.Load("Details.xml");

        foreach (string eachfile in Files)
        {
            try
            {
                FileInfo Info = new FileInfo(eachfile);

                toolStripStatusLabel1.Text = "Adding : " + Info.Name;

                // Create the Root element
                XmlElement ROOT = xml.CreateElement("File");

                if (checkBox1.Checked)
                {
                    XmlElement FileName = xml.CreateElement("FileName");
                    FileName.InnerText = Info.Name;
                    ROOT.AppendChild(FileName);
                }

                if (checkBox2.Checked)
                {
                    XmlElement FilePath = xml.CreateElement("FilePath");
                    FilePath.InnerText = Info.FullName;
                    ROOT.AppendChild(FilePath);
                }

                if (checkBox3.Checked)
                {
                    XmlElement ModificationDate = xml.CreateElement("ModificationDate");
                    string lastModification = Info.LastAccessTime.ToString();
                    ModificationDate.InnerText = lastModification;
                    ROOT.AppendChild(ModificationDate);
                }

                if (checkBox4.Checked)
                {
                    XmlElement CreationDate = xml.CreateElement("CreationDate");
                    string Creation = Info.CreationTime.ToString();
                    CreationDate.InnerText = Creation;
                    ROOT.AppendChild(CreationDate);
                }

                if (checkBox5.Checked)
                {
                    XmlElement Size = xml.CreateElement("Size");
                    Size.InnerText = Info.Length.ToString() + " Bytes";
                    ROOT.AppendChild(Size);
                }

                xml.DocumentElement.InsertAfter(ROOT, xml.DocumentElement.LastChild);

                // +1 step in progressbar
                toolStripProgressBar1.PerformStep();
                success_counter++;
                Thread.Sleep(10);
            }
            catch (Exception ee)
            {
                toolStripProgressBar1.PerformStep();

                error_counter++;
            }
        }

        toolStripStatusLabel1.Text = "Now Writing the Details File";

        xml.Save("Details.xml");

        toolStripStatusLabel1.Text = success_counter + " Items has been added and "+ error_counter +" Items has Failed , Total Files Processed ("+Files.Count+")";

        Files.Clear();
    }

Here is how the XML looks like after Generation of details :

<?xml version="1.0" encoding="utf-8"?>
 <Files>
  <File>
    <FileName>binkw32.dll</FileName>
    <FilePath>D:\ALL DLLS\binkw32.dll</FilePath>
    <ModificationDate>3/31/2012 5:13:56 AM</ModificationDate>
    <CreationDate>3/31/2012 5:13:56 AM</CreationDate>
    <Size>286208 Bytes</Size>
  </File>
 <File>

Example of characters i would like to parse to XML without issue :

BX]GC^O^_nI_C{jv_rbp&1b_H âo&psolher d) doိiniᖭ

icon_Áq偩侉₳㪏ံ�ぞ鵃_䑋屡1]

MAnaFor줡�

EDIT [PROBLEM SOLVED]

All i had to do is :
1- convert the file name to UTF8-Bytes
2- Convert the UTF8-Bytes back to string

Here is the method :

byte[] FilestoBytes = System.Text.Encoding.UTF8.GetBytes(Info.Name);
string utf8 = System.Text.Encoding.UTF8.GetString(FilestoBytes);
  • 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-02T03:30:56+00:00Added an answer on June 2, 2026 at 3:30 am

    Probably the xml is malformed. Xml files can not have some characters without being escaped.
    For example, this is not valid:

    <dummy>You & Me</dummy>
    

    Instead you should use:

    <dummy>You &amp; Me</dummy>
    

    Illegal characters in XML are &, < and > (as well as ” or ‘ in attributes)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an idea for a simple application which will monitor a group of
I have this idea for a free backup application. The largest problem I need
WPF can be infuriating sometimes. I have a fairly simple application that consists of
I frequently start with a simple console application to try out an idea, then
I have idea to write errors from my application to the Windows Event Viewer
Anyone have idea how to pass value from iPhone application to the REST-Webservice using
Is it good idea to have application engine written in c++ and user interface
I'm toying with the idea of phasing in an ORM into an application I
I have what I believe is a killer idea for an application. By definition,
I'm trying to build a simple application to download and play a music file.

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.