Click or drag to resize

RepositoryGetFileContentsEx Method (Options, FileSpec)

Return the contents of the files identified by the passed-in file specs.

Namespace:  Perforce.P4
Assembly:  p4api.net (in p4api.net.dll) Version: 2023.2.255.3501
Syntax
public IList<Object> GetFileContentsEx(
	Options options,
	params FileSpec[] filespecs
)

Parameters

options
Type: Perforce.P4Options
filespecs
Type: Perforce.P4FileSpec

Return Value

Type: IListObject
Remarks

p4 help print

print -- Write a depot file to standard output

p4 print [-a -A -k -o localFile -q -m max] file[revRange] ...
p4 print -U unloadfile ...

Retrieve the contents of a depot file to the client's standard output.
The file is not synced. If file is specified using client syntax,
Perforce uses the client view to determine the corresponding depot
file.

By default, the head revision is printed. If the file argument
includes a revision, the specified revision is printed. If the
file argument has a revision range, then only files selected by
that revision range are printed, and the highest revision in the
range is printed. For details about revision specifiers, see 'p4
help revisions'.

The -a flag prints all revisions within the specified range, rather
than just the highest revision in the range.

The -A flag prints files in archive depots.

The -k flag suppresses keyword expansion.

The -o localFile flag redirects the output to the specified file on
the client filesystem.

The -q flag suppresses the initial line that displays the file name
and revision.

The -m flag limits print to the first 'max' number of files.

The -U option prints files in the unload depot (see 'p4 help unload'
for more information about the unload depot).

Examples
To get the contents of the file //depot/MyCode/README.txt:
   GetFileContentsCmdOptions opts =
   new GetFileContentsCmdOptions(GetFileContentsCmdFlags.None, null);

FileSpec filespec =
new FileSpec(new DepotPath("//depot/MyCode/README.txt"), null);

   IList<String> target = Repository.GetFileContents(opts, filespec);
To get the contents of the file //depot/MyCode/README.txt redirecting the contents to local file C:\Doc\README.txt and supressing the file name and revision line:
   GetFileContentsCmdOptions opts =
   new GetFileContentsCmdOptions(GetFileContentsCmdFlags.Suppress,
   "C:\\Doc\\README.txt");

FileSpec filespec =
new FileSpec(new DepotPath("//depot/MyCode/README.txt"), null);

   IList<String> target = Repository.GetFileContents(opts, filespec);
See Also