replace - Replacing a file with a new file of the same name but different content in TFS via C# -
i´m working on programm updates templates on our companies team foundation server. having new templates locally on disk , want replace existing ones on server. trying different approaches , newest version. problem either
the new file "in use" when accessing through coding in c#(while not in use when try replace in runtime using normal explorer).
the replacement not appearing in pending changes, pendingchanges array initial.
using (var tfs = teamfoundationserverfactory.getserver("myserver")) { var versioncontrolserver = tfs.getservice(typeof(versioncontrolserver)) versioncontrolserver; // create new workspace authenticated user. var workspace = versioncontrolserver.createworkspace("temporary workspace", versioncontrolserver.authorizeduser); try { // check if mapping exists. var workingfolder = new workingfolder("$serverpath", @"c:\tempfolder"); // create mapping (if exists already, overides it, fine). workspace.createmapping(workingfolder); workspace.get(versionspec.latest, getoptions.getall); string[] paths = new string[1]; paths[0] = "test.pdf"; workspace.pendedit(paths, recursiontype.full, null, locklevel.none); // go through folder structure defined , create locally, check in changes. createfolderstructure(workspace, workingfolder.localitem); // check in changes made. int = workspace.checkin(workspace.getpendingchanges(), "this comment"); } catch (exception ex) { console.writeline(ex.message); } { // cleanup workspace. workspace.delete(); // remove temp folder used. directory.delete(@"c:\tempfolder", true); } } } static void createfolderstructure(workspace workspace, string initialpath) { workspace.penddelete("$serverpath/test.pdf", recursiontype.none); file.copy(@"c:\test\testnew.pdf", @"c:\tempfolder\test", true); workspace.pendadd(@"c:\tempfolder\test.pdf"); }
i found solution problem. workspace used "authorizeduser" not enough.. found out need teamfoundationidentity it. here guide on how fix issue.
Comments
Post a Comment