Inforeseau
dimanche 30 mai 2010 -
C#
0 commentaires
ecrire un fichier xml pour un fichier de config
XmlTextWriter xml = new XmlTextWriter(cheminDefichier, Encoding.ASCII); // instanciation de la classe xml xml.WriteStartDocument(true); // debut de notre fichier xml xml.Formatting = Formatting.Indented; // procédure d'indentation xml.WriteStartElement("configuration"); // debut de l'element root xml.WriteStartElement("connectionStrings"); // debut de l'element connectionStrings xml.WriteStartElement("add"); // debut de l'element add xml.WriteStartAttribute("name"); // ajout de l'attribut name à l'element add xml.WriteString("TIMETABLEASY"); xml.WriteStartAttribute("connectionString"); // ajout de l'attribut connectionString à l'element add xml.WriteString(chainedeconnexion); xml.WriteStartAttribute("providerName"); // ajout de l'attribut provider name à l'element add xml.WriteString("System.Data.SqlClient"); xml.WriteEndElement(); // fin de l'element add xml.WriteEndElement(); // fin de l'element connectionStrings xml.WriteEndElement(); // fin de l'element root xml.WriteEndDocument(); // fin de l'element root xml.Close(); File.SetAttributes(cheminDefichier, FileAttributes.Hidden); // fermeture du document XML
Articles plus récents
Articles plus anciens
Accueil
Inscription à :
Articles ( Atom )