What is the best way to transfer a “data string” from one C # console application to another C # console application?

I have a C # console application "App1" that reads a row of data from a table in a SQL Server 2005 database. I want App1 to pass all the data in that row to App2, another C # console application. What is the best way to do this?

My first (naive) attempt was to do this:

object[] o = myrow.ItemArray;
// make a string that separates each item by a space... for example "1 2 myVar".
// pass this string to App2 via command line.

This has some drawbacks: what if one of the entries in the line was "my var" instead of "myVar"? In addition, the order of the elements will be hard-coded in the receiving application (App2).

So what's the best way to do this? Would it be appropriate to pass the xml string to App2 through the command line?

Hooray!

+3
3

XML , , DataRow ( ) . DataTable .

DataTable XML , XML .

DataTable XML DataTable.WriteXml.

+3

, , , Process.Start - , - , : cd "c:\program files"

, , IPC-, , , WCF .. : (, xml) , .

+1

You can use a serialized DataSet to easily receive data from one place to another without having to write a lot of custom code, since the DataSet already provides the necessary methods by default (e.g. .WriteXML will serialize the DataSet for XML and write to a file). Then your other application could poll the appropriate directory for new files.

+1
source

Source: https://habr.com/ru/post/1697957/


All Articles