private static string[] ReadResponseFile(string strFileName){
FileStream inputStream = new FileStream(strFileName, FileMode.Open,
FileAccess.Read, FileShare.Read);
Int64 size = inputStream.Length;
if (size == 0)
return null;
StreamReader reader = new StreamReader(inputStream);
string curLineArgs = reader.ReadLine();
// This regular expression is: blank*(nonblanks|stringLiteral)+
string strReArgs = "\\s*([^\\s\\\"]|(\\\"[^\\\"\\n]*\\\"))+";
Regex re = new Regex(strReArgs);
StringCollection args = new StringCollection();
while (curLineArgs != null){
if (!curLineArgs.Trim().StartsWith("#", StringComparison.Ordinal)){
MatchCollection matches = re.Matches(curLineArgs);
if (matches != null && matches.Count != 0){
foreach (Match match in matches){
string arg = match.ToString().Trim();
int iQuotes = 0;
while ((iQuotes = arg.IndexOf("\"", iQuotes)) != -1){
if (iQuotes == 0)
arg = arg.Substring(1);
else if (arg[iQuotes-1] == '\\')
iQuotes += 1;
else
arg = arg.Remove(iQuotes, 1);
}
args.Add(arg);
}
}
}
curLineArgs = reader.ReadLine();
}
if (args.Count == 0)
return null;
string[] argStrings = new string[args.Count];
args.CopyTo(argStrings, 0);
return argStrings;
}