Page 1 of 1

How to access of prior version of a file?

Posted: Thu Apr 30, 2009 5:19 pm
by stanyork
We need to be able to access a prior version of a file based on its version number. In the VSS API, we had the current VSSItem and given the version number we could get any prior version using code like this:

Code: Select all

SourceSafeTypeLib.VSSItem theFile 
int theVersionNumber

return theFile.Version( theVersionNumber )  // return type is SourceSafeTypeLib.VSSItem 
The returned VSSITEM could then be used to GET that version or perform other operations.

Any hint as to what the equivalent would be is greatly appreciated!

(Yes, our VSS API code has lots of error handling for all the senarios where the above code fails because the history/version entry is a branch or a whatever that isn't really real.... but that isn't relevant right now)

Re: How to access of prior version of a file?

Posted: Thu Apr 30, 2009 6:01 pm
by shannon
What version of the api are you working with?

Re: How to access of prior version of a file?

Posted: Fri May 01, 2009 6:22 am
by stanyork
VaultClientIntegrationLib.dll is 4.1.4.18402

Re: How to access of prior version of a file?

Posted: Fri May 01, 2009 7:21 am
by shannon
Take a look at GetOperations.ProcessCommandGetVersion(string objectPath, int version, GetOptions getOptions) which uses a working folder
or GetOperations.ProcessCommandGetVersionToLocationOutsideWorkingFolder(string objectPath, int version, GetOptions getOptions, string destPath) to get to a non-working folder.

Re: How to access of prior version of a file?

Posted: Fri May 01, 2009 7:35 am
by stanyork
I agree, the suggested methods will GET the file out of source control....but how do I obtain the object in memory that gives me information about the particular version (date, who, etc).

I am looking for the equivalent of VSSITEM for a historical version.

So, your VaultClientFile has
  • GetFileProperties method that returns a VaultFileProperties, and VaultFileProperties has a .LatestVersion property
  • Version property that returns a version number -- implying that the VaultClientFile.Version may not equal VaultFileProperties.LatestVersion
So I may be asking: how do I get a VaultClientFile object for some arbitrary prior version of a file.

Re: How to access of prior version of a file?

Posted: Fri May 01, 2009 7:51 am
by shannon
Sorry, I misunderstood what you wanted. Ok, I talked with a coworker and I don't think we have an equivalent of this VSSITEM. You'll probably need to perform a history query and look through the results to get the information you're looking for.

ServerOperations.ProcessCommandHistory might be a place to start.