Можно найти любое управление при помощи свойство UniqueID:
Label label = (Label)Page.FindControl("UserControl1$Label1");
Ваш подход действителен.
Ваша ошибка находится в пути вашего проекта. Вместо этого используйте что-то вроде этого:
string projectPath = "$/PathToApp/TestApp";
Я согласен с Джораджем в том, что, вероятно, виноват ваш путь к серверу. Чтобы лучше понять, что происходит, вам нужно подключить некоторые события к объекту VersionControlServer. Как минимум вам понадобятся сообщения Getting, NonFatalError и Conflict.
Полный список: http://msdn.microsoft.com/en-us/library/microsoft.teamfoundation.versioncontrol.client.versioncontrolserver_events (VS. 80) .aspx
I ended up using a different approach that seems to work, mainly taking advantage of the Item.DownloadFile()
method:
VersionControlServer sourceControl; // actually instantiated...
ItemSet items = sourceControl.GetItems(sourcePath, VersionSpec.Latest, RecursionType.Full);
foreach (Item item in items.Items)
{
// build relative path
string relativePath = BuildRelativePath(sourcePath, item.ServerItem);
switch (item.ItemType)
{
case ItemType.Any:
throw new ArgumentOutOfRangeException("ItemType returned was Any; expected File or Folder.");
case ItemType.File:
item.DownloadFile(Path.Combine(targetPath, relativePath));
break;
case ItemType.Folder:
Directory.CreateDirectory(Path.Combine(targetPath, relativePath));
break;
}
}