Bonjour,
Donc j'ai un petit soucis avec mon string ;) . En fait du coté de mon service, j'ai 2 méthode qui me permette de concaténer 2 fichier XML.
public string ReadXml(string FileName)
{
StreamReader re = File.OpenText(FileName);
string input2 = null;
while ((input2 = re.ReadLine()) != null)
{
m_stconcat2 = String.Concat(m_stconcat2, input2);
}
re.Close();
return m_stconcat2;
}Cette première méthode me permet de récupérer un fichier XML qui contient ces données:
<data>
<file>a</file>
<command>b</command>
<type>stream</type>
<loop>1</loop>
<id>0</id>
<ip>239.2.12.1</ip>
<port>123</port>
<ip_bind>127.0.0.1</ip_bind>
</data>Ensuite, j'ai une 2e méthode qui me permet de concaténer ce fichier avec un autre fichier XML :
public string CreateTemp()
{
string XMLfile = "c:\\temp.xml";
StreamReader re = File.OpenText(XMLfile);
string input = null;
while ((input = re.ReadLine()) != null)
{
m_stconcat = String.Concat(m_stconcat, input);
}
Console.WriteLine(m_stconcat);
re.Close();
input = ReadXml("c:\\file00.xml");
m_stconcat = String.Concat(m_stconcat, input);
m_stconcat = String.Concat(m_stconcat, "</NewDataSet>");
return m_stconcat;
}Cette méthode me permet donc de concaténer le fichier temp.xml avec le fichier file00.xml avec comme résultat :
<?xml version="1.0" standalone="yes"?>
<NewDataSet>
<xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true" msdata:EnforceConstraints="False">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="table1">
<xs:complexType>
<xs:sequence>
<xs:element name="file" type="xs:string" minOccurs="0" />
<xs:element name="command" type="xs:string" minOccurs="0" />
<xs:element name="type" type="xs:string" minOccurs="0" />
<xs:element name="id" type="xs:string" minOccurs="0" />
<xs:element name="ip" type="xs:string" minOccurs="0" />
<xs:element name="port" type="xs:string" minOccurs="0" />
<xs:element name="ip_bind" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<?xml version="1.0"?>
<data>
<file>a</file>
<command>b</command>
<type>stream</type>
<loop>1</loop>
<id>0</id>
<ip>239.2.12.1</ip>
<port>123</port>
<ip_bind>127.0.0.1</ip_bind>
</data>
</NewDataSet>et donc cette concaténation est retournée dans un string.
De mon coté client, je veux récupérer ce string pour le mettre dans un GridView :
DataSet m_dsSet = new DataSet();
string m_sta = String.Format("{0}", obj.CreateTemp());
Stream readDs = new FileStream(m_sta, FileMode.Open);
m_dsSet.ReadXml(readDs);
readDs.Close();
DataGrid1.DataSource = m_dsSet;
DataGrid1.DataBind();Mais j'ai une erreur du style :
illegal charater in path:
Line 224: Stream readDs = new FileStream(a, FileMode.Open);+
Donc si quelqu'un pouvait m'aider, ca m'arranger beaucoup.
Merci d'avance ;)