Find vault location for a file under source control.

Post your questions regarding using the Vault and Fortress API in your programs.

Moderator: SourceGear

Post Reply
pjmartins
Posts: 5
Joined: Fri Oct 08, 2010 7:13 am

Find vault location for a file under source control.

Post by pjmartins » Fri Oct 08, 2010 7:23 am

I have a project open in Visual Studio 2010 which is under source control via Vault. Is there a way to check out a file in this project via API based on its location on the local hard drive rather than its location in Vault? Or is there a way to find the repository location via API for a given working folder, in this case the folder which the project is located under on the local hard drive?

lbauer
Posts: 9736
Joined: Tue Dec 16, 2003 1:25 pm
Location: SourceGear

Re: Find vault location for a file under source control.

Post by lbauer » Fri Oct 08, 2010 9:45 am

If you have a working folder, you can call:

Code: Select all

ClientInstance.TreeCache.GetCorrespondingRepositoryPath(string diskPath)
which should give you a repository path.
Linda Bauer
SourceGear
Technical Support Manager

pjmartins
Posts: 5
Joined: Fri Oct 08, 2010 7:13 am

Re: Find vault location for a file under source control.

Post by pjmartins » Fri Oct 08, 2010 3:29 pm

Function returns null each time. I used SetActiveRepositoryID to set the corresponding repository correctly. I also verified that the desired vault path of the file can be found:

Code: Select all

((VaultClientOperationsLib.VaultClientFolder)ClientInstance.TreeCache.Repository.Root.Folders[i]).Files[j]
Interestingly, when I try to call

Code: Select all

ClientInstance.GetWorkingFileName(VaultClientFile)
on the above VaultClientFile I get an object reference not set exception and calling GetWorkingFolder on the VaultClientFolder returns null. What else am I missing?

lbauer
Posts: 9736
Joined: Tue Dec 16, 2003 1:25 pm
Location: SourceGear

Re: Find vault location for a file under source control.

Post by lbauer » Thu Oct 14, 2010 3:21 pm

If the project is open in VS, then your best bet is to check it out in VS. We don't have an API which interacts with the Enhanced client, so any check out would not show up until the user refreshed the file status from within VS.

It might help us to know why you're wanting the check out a file outside of Visual Studio if Visual Studio is open.
Linda Bauer
SourceGear
Technical Support Manager

pjmartins
Posts: 5
Joined: Fri Oct 08, 2010 7:13 am

Re: Find vault location for a file under source control.

Post by pjmartins » Fri Oct 15, 2010 11:40 am

Thank you, turns out my problem was I was trying to find the location in VS using different credentials which is why GetCorrespondingRepositoryPath did not work. Thanks again for your help.

lbauer
Posts: 9736
Joined: Tue Dec 16, 2003 1:25 pm
Location: SourceGear

Re: Find vault location for a file under source control.

Post by lbauer » Fri Oct 15, 2010 3:07 pm

Thanks for the update. That's good news. : )
Linda Bauer
SourceGear
Technical Support Manager

Post Reply