Simple client server to send XML information to CRUD database

147 views Asked by At

I need to develop a resident app to get info from Win32_BaseBoard class when is required by another app by XML without create any file and then this app must insert or update that information on database.

I saw a few apps but always have to create a file and i don't know if already exists something like that.

1

There are 1 answers

0
jdweng On

The code below will create memory stream with the data instead of writing to a file.

            ///old code
            //XmlSerializer serializer = new XmlSerializer(typeof(AppConfig));
            //StreamWriter writer = new StreamWriter(FILENAME);
            //serializer.Serialize(writer, config);

            //new code
            string input = "Your XML here";
            string output = "";
            XmlSerializer serializer = new XmlSerializer(typeof(AppConfig));

            MemoryStream mstream = new MemoryStream(Encoding.UTF8.GetBytes(input));
            StreamWriter writer = new StreamWriter(mstream);
            serializer.Serialize(writer, config);
​