You will need to use VersionControlServer.QueryHistory in a manner similar to the following method. Pay particular attention to SlotMode , which must be false in order for renames to be executed.
private static void PrintNames(VersionControlServer vcs, Change change) {
EDIT: Moved another solution. What follows is when I tested a clean Rename change, but it broke when I got tired of the Rename and Edit changes.
This is probably the most efficient way to get the previous name. Although it works (TFS2013 API vs TFS2012 install), it looks like an error to me.
private static string GetPreviousServerItem(VersionControlServer vcs, Item item) { Change[] changes = vcs.GetChangesForChangeset( item.ChangesetId, includeDownloadInfo: false, pageSize: int.MaxValue, lastItem: new ItemSpec(item.ServerItem, RecursionType.None)); string previousServerItem = changes.Single().Item.ServerItem;
It will be used as:
if (change.ChangeType.HasFlag(ChangeType.Rename)) { string oldServerPath = GetPreviousServerItem(vcs, change.Item);
source share