I have the C# code below, used to input each file in a directory, run an XQuery process on it, and output each file as an XML file. The code calls the SAXON XQuery processor. Note: the code works now but it only processes the first file in the directory. The second, third, etc. output files from the input directory come back as empty XML files. Question: how do I modify the code to process all the files (not just the first one) in the input directory?
public void 开发者_如何学JAVAOpenWithArguments(string t)
{
string sourceDir = t;
string [] fileEntries = Directory.GetFiles(sourceDir);
foreach (string fileName in fileEntries)
{
Process process = new Process();
process.StartInfo.FileName = @"C:\Program Files\Java\jdk6\bin\java";
process.StartInfo.CreateNoWindow = true;
process.StartInfoArguments =
@" -cp C:\mydir\saxon9he.jar net.sf.saxon.Query -o:C:\myOutPutFiles\" +
Path.GetFileNameWithoutExtension(fileName) +
@".xml C:\myQueries\myquery.xquery input=" +
Path.GetFileNameWithoutExtension(fileName);
process.Start();
process.Close();
}
}
Try adding process.WaitForExit() after you start it.
精彩评论