i edited my code to the following:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace Search
{
class Program
{
static void Main(string[] args)
{
string abc = string.Format("{0}", args[0]);
string latestversion = string.Format("{1}", args[1]);
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = "sslist.exe";
p.StartInfo.Arguments = "-R -H -h sinsscm01.ds.net" + type;
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.Start();
string procOutput = p.StandardOutput.ReadToEnd();
string procError = p.StandardError.ReadToEnd();
TextWriter outputlog = new StreamWriter("C:\\Work\\listofsnapshot.txt");
outputlog.Write(procOutput);
outputlog.Close();
string greatestVersionNumber = "";
using (StreamReader sr = new StreamReader("C:\\Work\\listofsnapshot.txt"))
{
while (sr.Peek() >= 0)
{
var line = sr.ReadLine();
var versionNumber = line.Replace(latestversion, "");
if(versionNumber.Length != line.Length)
greatestVersionNumber = versionNumber;
}
}
Console.WriteLine(greatestVersionNumber);
TextWriter latest = new StreamWriter("C:\\Work\\latestbuild.properties");
latest.Write("Version_Number=" + greatestVersionNumber);
latest.Close();
}
}
}
where string type and string latest version are the arguments parsed.
So, my commandline looks like this:
c:/searchversion.exe "/SASE Lab Tools" "6.70_Extensions/6.70.102/ANT_RELEASE_"
where "/SASE Lab Tools" should be stored as a string abc and "6.70_Extensions/6.70.102/ANT_RELEASE_" should be stored as a string as latestversion.
However i get an error: System.Format.Exception: Index(zero based) must be greater than or equal to zero and less than the size of the argument list at line 14:
string latestversion = string.Format("{1}", args[1]);
Anybody knows whats wrong?
for
You specified the 2nd item in the array of the string format, for which there isnt one. So the array is out of bounds. you meant