How can I encode a Process in C# to send by Sockets?

53 Views Asked by At

I'm a junior programmer. I need to send by Sockets a Process between a Windows Service and a WPF. I want to know how can I encode a Process to send and execute it in the Service. Actually I know how I can send a String or a Integer, but no how to send a Process like:

            {
                StartInfo = new ProcessStartInfo
                {
                    RedirectStandardOutput = true,
                    UseShellExecute = false,
                    CreateNoWindow = true,
                    WindowStyle = ProcessWindowStyle.Hidden,
                    FileName = shell,
                    Arguments = $"-c \"{escapedArgs}\""
                }
            };````

To encode a String I use:
````// Connect to Remote EndPoint
                sender.Connect(remoteEP);

                Console.WriteLine("Socket connected to {0}",
                    sender.RemoteEndPoint.ToString());

                // Encode the data string into a byte array.
                byte[] msg = Encoding.ASCII.GetBytes("This is a test<EOF>");

                // Send the data through the socket.
                int bytesSent = sender.Send(msg);````

There is some Encode.(Function)? I have to create a new function?
Thank you!
0

There are 0 best solutions below