I want to be able to interrogate TfsTeamProjectCollection and determine if there is a newer version of a file on the server. I would like to be able to do this without actually fetching the file.
Is this possible somewhere? I've done some scratching around and so far drawing blanks.
Thanks.
The easiest way is to
QueryHistory
between the workspace version and the latest version; if they differ, there exists a newer latest version on the server. Eg://We have to specify files which are already mapped with local workspace for compare here
This is another way to check whether a given file is latest or not.
STEPS
1) We need to get the
Workspace
that contains the file path. We useWorkstation.GetLocalWorkspaceInfo Method (String)
to get
WorkspaceInfo
object which contains properties of the Workspace that contains the specified file.We can use this
WorkspaceInfo
object to get the instance of that workspace by usingWorkspaceInfo.GetWorkspace Method (TfsTeamProjectCollection)
2) Now we need to perform a
Get
Operation with the workspace object.Workspace.Get Method (GetRequest[], GetOptions)
The second parameter,
GetOptions
has six possible member values. Each with a purpose.Since you don't need to download the file,
we will use the member value
Preview
whichExecutes a get without modifying the disk.
3) The
Get
operation returns aGetStatus
object which represents the status of aWorkspace.Get
operation.This contains information about how many operations, conflicts, errors, and so on occurred when the
Get
operation was being processed.GetStatus
object has a number of properties. We use property calledNoActionNeeded
which gets a flag that indicates whether no failures and no operations occurred.The flag value will be True if no operations or errors occurred. ie, the file is already the latest version. Otherwise the flag will be False which means the file is not the latest version available in TFS.