2011-01-20 18 views
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; 
    } 

回答

0
E:\VobName\Sampledir 

是一個驅動器號分配給路徑。請參閱Windows command subst
您是否嘗試過實際的視圖完整路徑?

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

或:

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

原註釋的路徑是完整路徑。我有一個專用於靜態視圖的分區(E:\\)。 – JGoforth 2011-01-24 15:01:00

相關問題