【发布时间】:2011-01-20 20:56:53
【问题描述】:
我正在尝试从 C# 应用程序中获取特定目录中的私有视图列表。
我正在使用以下函数进行调用:
ClearCommand = "ls -r -view_only"
和
directory = @"E:\VobName\sampleDir".
返回:
cleartool: Error: Pathname is not within a VOB: "E:\VobName\Sampledir"
如果我在 E:\VobName\sampleDir 内的 windows 命令提示符下执行相同的命令,它工作正常。
知道为什么它的运行方式会出现这种不一致吗?
以下是相关代码:
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;
}
【问题讨论】:
标签: c# clearcase cleartool processstartinfo