Click here to Skip to main content
15,887,854 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am building an app, which should have a functionality to copy files from a local folder and save it in TFS on a button click. I did lot of googling to get a solution for this purpose , I couldn't find an apt one. So, my question is, is it possible to add new files to TFS programatically using C#?. If yes, then is there any restriction on the file types we can add to TFS?. if we can add new files from a local folder to TFS programmatically, can someone please provide me a reference code for the same?. Thanks in advance

What I have tried:

I have tried creating a workspace and add file to the workspace using PendAdd method. The workspace is getting created, but I couldn't find the workspace in the TFS. Below is the code I have used to create the workspace

TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(new Uri(<tfs uri>));

tfs.EnsureAuthenticated();
VersionControlServer vcs = tfs.GetService<versioncontrolserver>();
Workspace ws = vcs.CreateWorkspace("DCSCode");

//"I:temp" is the location of files which needs to be
//moved to TFS
int r = ws.PendAdd(@"I:temp");
Posted
Updated 25-Jun-18 21:58pm

1 solution

 
Share this answer
 
Comments
Member 13333663 26-Jun-18 7:09am    
Hi, Thanks for the solution. But the link provided explains how to copy files from existing repository to a workspace and edit the same/add new files. But I do not have any files in repository, I have to add an existing file in my local folder to TFS.It would be helpful if you could provide me a reference for adding and existing file from local to TFS.
Kornfeld Eliyahu Peter 26-Jun-18 7:24am    
Here is the reference for the whole API: https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2013/bb171828(v%3dvs.120)
Probably PendAdd will be usefull...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900