How do I get the filename of an Item?? - Team Foundations SDK
I am trying to get a file by name from TFS. I am getting all the files from a location recursively and then looping through these to find a specific file. It appears that the VersionControl.Client.Item object does not expose the filename (or foldername).
tfs.EnsureAuthenticated();
VersionControlServer vcs = versionControlServer)tfs.GetService(typeof(VersionControlServer));
var allStaticFiles = vcs.GetItems(path + "*", RecursionType.Full).Items;
foreach (var staticFile in allStaticFiles)
{
if(staticFile == ?? // need the开发者_运维问答 filename)
{
}
(Assuming TFS2008.)
The type of vcs.GetItems(...).Items
is Item[]
.
So therefore staticFile
is an Item
instance.
The properties of Item
are all server side because details of the path will depend on the client's workspace mapping (there can be multiple workspaces including this item on the same computer for the same user).
You can use Item.ServerItem
to get the filename (take the last path element)
To the path, get a Workspace
instance representing your current workspace and use one of its methods to map the ServerItem
to a local path (there are a few with subtly different behaviour, without more context it is not clear which is the right one).
精彩评论