1

I'm using the Perforce .NET APIs P4API.NET library and wonder if there is a "p4 files" command line equivalence that I can call to return a listing of files (such as *.cpp) in my //depot? Thanks in advance!

Ganesh Sittampalam
  • 28,821
  • 4
  • 79
  • 98
Kevin
  • 515
  • 4
  • 11
  • 22

2 Answers2

1

A quick tour around the docs doesn't immediately reveal anything, but you could always use P4Command.Run to run any arbitrary Perforce command, so you could still run p4 files //depot/...cpp.

Mark
  • 3,609
  • 1
  • 22
  • 33
  • How do I get the output back from p4Command.Run for the "p4 files ..." command? – Kevin Aug 16 '12 at 01:01
  • 1
    The introduction in the docs I linked to in my answer will give you that answer. `P4CommandResult results = cmd.Run(opts);` – Mark Aug 16 '12 at 01:17
1

Here's a code snippet that works for me.

IList<FileSpec> filesToFind = new List<FileSpec>();
FileSpec fileToFind = new FileSpec(new DepotPath("//depot/....cpp"), null, null, VersionSpec.Head);
filesToFind.Add(fileToFind);
IList<FileSpec> filesFound = pRep.GetDepotFiles(filesToFind, null);
randy-wandisco
  • 3,649
  • 16
  • 11
  • When a depot path has no file, I got an exception from pRep.GetDepotFiles(fileToFind, null) instead of it returning null. The exception is: "Object reference not set to an instance of an object". What am I missing? Thanks. – Kevin Oct 17 '12 at 19:42