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

  1. the new file "in use" when accessing through coding in c#(while not in use when try replace in runtime using normal explorer).

  2. 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.

http://blogs.msdn.com/b/taylaf/archive/2010/03/29/using-tfs-impersonation-with-the-version-control-client-apis.aspx


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -