にクライアントからそれを送って、私は2 clases持っている:XMLSERIALIZEクラスとサーバー
public class products
{
public string category;
public string name;
public double price;
public string desc;
public string version;
public string logoURL;
public string imgURL;
public string prod;
public string Category
{
set { categorie = value; }
get { return category; }
}
と:
[Serializable()]
public class groupProducts
{
public products[] produse;
}
を私はgroupProductsクラスをXMLSERIALIZEし、TCPを介してサーバからデータを送信したいですクライアントへの接続!以下のような 私が試した何か:
groupProducts gp = new groupProducts();
XmlSerializer xmlSel = new XmlSerializer(typeof(groupProducts));
TextWriter txtStream = new StreamWriter("xmlStreamFile.xml");
xmlSel.Serialize(txtStream, gp);
txtStream.Close();
try
{
Stream inputStream = File.OpenRead("xmlStreamFile.xml");
// declaring the size of the byte array to the length of the xmlfile
msg = new byte[inputStream.Length];
//storing the xml file in the byte array
inputStream.Read(msg, 0, (int)inputStream.Length);
//reading the byte array
communicator[i].Send(msg);
}
が、それを私はクライアント側でそれをデシリアライズするとき - XMLファイルは、その中にいくつかの奇妙なデータを持っています!
あなたは何ができるか考えていますか?私は間違って何をしていますか?
「奇妙なデータ」を定義します。それでも有効なXMLですか? –
はい - それはまだXMLデータでしたが、その一部だけでした!私はそれを修正することができましたが、今度はデータが2回書き込まれます! – Alin
私はそれが何を意味するのか分かりません。 –