Bonjour,

Je travaille sur un projet en c#, j'ai besoin de créer et modifier un fichier xml, pour créer un fichier xml j'utilise le code suivant (au sein du main):

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using System;
using System.Linq;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Xml;
 
namespace AgentTest
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [MTAThread]
        static void Main()
        {
            XmlDocument docxml = new XmlDocument();
 
            //on crée le premier noeud avec les spécifications du document XML
            XmlDeclaration declaration = docxml.CreateXmlDeclaration("1.0", "utf-8", "");
            //On ajoute la déclaration au document
            docxml.AppendChild(declaration);
 
            //On crée le noeud racine du document
            XmlNode racine = docxml.CreateNode(System.Xml.XmlNodeType.Element, "RapportKMS", "");
            //On ajoute ce noeud au document
            docxml.AppendChild(racine);
            docxml.Save("RapportKMS.xml");
            Application.Run(new AgentKMS());
        }
    }
}
Le problème est que ce code ne marche pas au sein de mon projet, or lorsque je le met tout seul dans un nouveau projet ça marche très bien.

Et merci d'avance.