views:

29

answers:

4

Some sample code:

var psi = new ProcessStartInfo();
psi.FileName = "path to update.exe";
psi.Arguments = "arguments for update.exe";
psi.Verb = "runas";

var process = new Process();
process.StartInfo = psi;
process.Start();   
process.WaitForExit();

Ref: 0xA3.

Programmatically in code what type of objects if possible could you pass into the '.Arguments' property? Typically you can pass an int or a string type. I want to know if you could pass in a more complicated type like a DirectoryInfo[] or a FileInfo[]? Would anyone know if this is possible? If not i'll have to come up with something else?

Why? I am trying to remove some problem code from a very large background worker and the only solution is to pass the data I require into a process that will handle the work I need doing in a completey different process. Problem this problem code always throws up on permissions - permissions the app does not have.

A: 

The arguments are exactly what you'd type (with leading and trailing quotes), if you were running the .exe from the command prompt.

Use strings.

ChrisA
I have come up with my solution. I was over complicated my problem and was being lazy .. i can step further back in code and use a string. I will post my solution very soon.
IbrarMumtaz
A: 

As defined the Arguments property is of type string so you could only pass space delimited arguments to the process the same way you would when calling it at the command line.

Darin Dimitrov
A: 

No, this isn't possible.

You should consider making a new AppDomain in your existing process.

SLaks
I figured as much. It was worth a shot :)
IbrarMumtaz
+1  A: 

- Allocate the object into global memory then pass the resulting IntPtr, in Arguments, to the other process.

AMissico
Option 2 is exactly what I had in mind as my alternative solution. +1! Could elaborate further on option 1 or 3 ???
IbrarMumtaz
@IbrarMumtaz: I update answer with a refernce to sample code that transfers a string to the other process and removed third option because it is too hard.
AMissico