0

I'm starting a new process with:

process.Start();

I know I can pass strings to it using:

process.StartInfo.Arguments = ...

But I want to share more than just a couple of simple strings – a byte array etc. How do I do that?

EDIT: This is going to be installed as a ClickOnce application, so I don't really know where it will be installed in the file system, and I want to keep it as simple as possible so no files will remain after an uninstall. So where do I put this data?

ispiro
  • 26,556
  • 38
  • 136
  • 291

5 Answers5

3

Take a look at memory mapped files - they allow you to share data between processes.

Alternatives are regular files, the registry, communicating over sockets and more.

Oded
  • 489,969
  • 99
  • 883
  • 1,009
2

If the array is small you can just base64 encode it. Other options consist of saving data to the file or using named pipes

Jakub Konecki
  • 45,581
  • 7
  • 87
  • 126
  • Thanks. Base64 is probably the closest to what I'm looking for. Unless arguments of other types (besides strings) can be passed to a process in some way that nobody here has found. – ispiro May 28 '12 at 18:02
0

You may want to use Anonymous Pipes.

Anonymous pipes offer less functionality than named pipes, but also require less overhead. You can use anonymous pipes to make interprocess communication on a local computer easier. You cannot use anonymous pipes for communication over a network.

Adam
  • 26,549
  • 8
  • 62
  • 79
0

You can create a temp file, write all required data into it and send result file name as a command line argument. When the second application run it will read the content of file and delete it.

Viacheslav Smityukh
  • 5,652
  • 4
  • 24
  • 42
0

if you can encode the byte array properly (e.g. base64), you can redirect stdin of the target process and stream it through that:

http://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.redirectstandardinput.aspx

silijon
  • 922
  • 1
  • 8
  • 19