gpt4 book ai didi

c# - cleartool 在命令提示符和 C# 应用程序中的行为不同

转载 作者:太空宇宙 更新时间:2023-11-03 16:49:09 26 4
gpt4 key购买 nike

我正在尝试从 C# 应用程序中获取特定目录中的私有(private) View 列表。
我正在使用下面的函数进行调用:

ClearCommand = "ls -r -view_only" 

directory = @"E:\VobName\sampleDir". 

它返回:

cleartool: Error: Pathname is not within a VOB: "E:\VobName\Sampledir"

如果我在 Windows 命令提示符下从 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:\VobName\Sampledir

是分配给路径的驱动器号。查看Windows command subst .
您是否尝试使用 View 的实际完整路径?

(snapshot view)
C:\path\to\myView\VobName\Sampledir

或:

(dynamic view)
M:\myView\VobName\Sampledir

关于c# - cleartool 在命令提示符和 C# 应用程序中的行为不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4752502/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com