2
我試圖從C#
應用程序中獲取特定目錄中的視圖私有列表。
我使用下面的功能,使這個電話有:cleartool在命令提示符和C#應用程序之間行爲不一致
ClearCommand = "ls -r -view_only"
和
directory = @"E:\VobName\sampleDir".
它返回:
cleartool: Error: Pathname is not within a VOB: "E:\VobName\Sampledir"
如果我在窗口做同樣的命令命令提示符從E:\VobName\sampleDir
,它工作正常。
任何想法爲什麼會有這種不一致的方式運行?
下面是相關代碼:
private String RunCommand(String clearCommand, String directory)
{
String retVal = String.Empty;
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = "cleartool";
startInfo.Arguments = clearCommand;
startInfo.UseShellExecute = false;
startInfo.CreateNoWindow = true;
startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardError = true;
startInfo.WorkingDirectory = directory;
try
{
// Start the process with the info we specified.
// Call WaitForExit and then the using statement will close.
using (Process process = Process.Start(startInfo))
{
//exeProcess.WaitForExit();
// Read in all the text from the process with the StreamReader.
using (StreamReader reader = process.StandardOutput)
{
retVal = reader.ReadToEnd();
}
if (String.IsNullOrEmpty(retVal))
{
// Read in all the text from the process with the StreamReader.
using (StreamReader reader = process.StandardError)
{
retVal = reader.ReadToEnd();
}
}
}
}
catch
{
Debug.Assert(false, "Error sending command");
}
return retVal;
}
原註釋的路徑是完整路徑。我有一個專用於靜態視圖的分區(E:\\)。 – JGoforth 2011-01-24 15:01:00