workspace.PendAdd() exact syntax?

落爺英雄遲暮 提交于 2019-12-25 14:50:01

问题


I am unable to add a new file using tfs sdk:

 int a = workspace.PendAdd(path,recursive );

What is this argument "Path"? path of file where to add or from where to add?

or before using this method v have to copy the new file in this folder?


回答1:


If you are trying to add a folder, the directory has to exist first. If you are trying to add a file, the file has to exist first. After that you can run, for example:

TeamFoundationServer tfs = TeamFoundationServerFactory.GetServer("http://WhateverServerUrl");
VersionControlServer VsServer = (VersionControlServer)tfs.GetService(typeof(VersionControlServer));
Workspace ws = VsServer.GetWorkspace("WORKSPACE_NAME", "WORKSPACE_OWNER");
ws.PendAdd(@"C:\MyFolder", true);

Keep in mind that the identity exec this command needs to have permissions to create the folder if in fact you are creating a folder.

So to create a folder though of course you would have to add code to do assuming it doesn't already exist:

System.IO.Directory.CreateDirectory(@"C:\MyFolder");


来源:https://stackoverflow.com/questions/6526373/workspace-pendadd-exact-syntax

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