In TFS, How do i check if a file is latest or not using C# code?

谁说我不能喝 提交于 2019-12-10 18:55:20

问题


How do i check if all the files in a folder are latest or not. I need to put up a condition in C# code which should get latest version of the project only if there is any file in the project folder having the latest as "No"?

Any help wpould be greatly appreciated.


回答1:


There's a few ways that you could do this programmatically, but the easiest way is to let the server determine this for you: if you perform a get latest with the preview get option set, it will not actually perform the get, it will simply tell you what would be retrieved to bring you up to the latest version.

For example:

GetStatus status = workspace.Get(new GetRequest(null, VersionSpec.Latest), GetOptions.Preview);

if(status.NumOperations == 0)
{
    /* All files up to date. */
}
else
{
    /* We are not up to date on some files. */
}


来源:https://stackoverflow.com/questions/6648814/in-tfs-how-do-i-check-if-a-file-is-latest-or-not-using-c-sharp-code

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!