Grab an old version

If you are having a problem using Vault, post a message here.

Moderator: SourceGear

Post Reply
realtytrac
Posts: 34
Joined: Wed Jun 15, 2005 2:07 pm

Grab an old version

Post by realtytrac » Tue Jun 28, 2005 4:57 pm

using the API, how can i select an old version of a file, and copy to some other location on my system.

this is where i am right now:

VaultClientFolder searchFolder = _myClient.Repository.Root.FindFolderRecursive(vaultfileFolder);
VaultClientFile vaultFile = new VaultClientFile();
RecursivelySearchForFileName(searchFolder,newfilePath,ref vaultFile);

string diskFileInVault = _myClient.TreeCache.PhysicalPath(vaultFile);
_myClient.
StreamReader sr = new StreamReader(diskFileInVault);
string fileData = sr.ReadToEnd();
newFile = new FileInfo(dir.FullName + "\\" + newfilePath);
StreamWriter sw = newFile.CreateText();

right now, that is getting me the most latest version of the file because it is accessing the physical disk of where it is saved. How can get the data of a previous version?

thanks

Haider

jeremy_sg
Posts: 1821
Joined: Thu Dec 18, 2003 11:39 am
Location: Sourcegear
Contact:

Post by jeremy_sg » Wed Jun 29, 2005 7:10 am

Haider,

You can fetch an old version with ClientInstance.GetByDisplayVersionToNonWorkingFolder if you don't need to check it in.

Code: Select all

VaultClientFile clone = vaultFile.Clone()
clone.Version = 4;
clone.ObjVerID = 0;
GetByDisplayVersionToNonWorkingFolder(clone, MakeWritableType.MakeAllFilesWritable, SetFileTimeType.Current, "C:\\temp", vaultFile.Parent.FullPath, null);

Post Reply