Reputation: 309
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = true;
startInfo.UseShellExecute = false;
startInfo.FileName = @".\ext.exe";
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
int i=0;
string item = listView1.Items[i++].Text;
startInfo.Arguments = "--logfile=duration_output.txt " + (item);
I am trying to list all items as a string[]
, but then the application gives me an empty logfile.
When I use the simple string item = listView1.Items[i++].Text
, it gives me only one the first file on the output.
How is it possible to do that?
Upvotes: 3
Views: 13899
Reputation: 18843
//here is something you can use getting directly at System.Diagnostics // it works just replace Console.WriteLine with what ever Stream Class you are using. //Replace where I use System.Diagnostics with ListView Iterate thru the listview itesm
System.Diagnostics.Process[] proc = System.Diagnostics.Process.GetProcesses();
foreach(Process theprocess in proc)
{
Console.WriteLine("Process: {0} ID: {1}", theprocess.ProcessName, theprocess.Id);
}
Upvotes: -1
Reputation: 217293
Are you looking for something like this?
startInfo.Arguments = "--logfile=duration_output.txt " +
string.Join(" ", from item in listView1.Items.Cast<ListViewItem>()
select @"""" + item.Text + @""""
);
Upvotes: 3
Reputation: 499002
You need to iterate over all the items in the listview and concatenate them into a single string:
string item = string.Empty;
foreach (ListViewItem anItem in listView1.Items)
{
item += " " & anItem.Text;
}
Upvotes: 2
Reputation: 19692
Try this:
string[] items = listView1.Items.Select(x => x.Text).ToArray();
Upvotes: 1
Reputation: 124642
StringBuilder args = new StringBuilder();
args.Append("--logfile=duration_output.txt");
foreach( var str in listView1.Items )
{
args.Append( " " );
args.Append( str );
}
Upvotes: 0