Find vault location for a file under source control.
Moderator: SourceGear
Find vault location for a file under source control.
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?
Re: Find vault location for a file under source control.
If you have a working folder, you can call:
which should give you a repository path.
Code: Select all
ClientInstance.TreeCache.GetCorrespondingRepositoryPath(string diskPath)
Linda Bauer
SourceGear
Technical Support Manager
SourceGear
Technical Support Manager
Re: Find vault location for a file under source control.
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:
Interestingly, when I try to call 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?
Code: Select all
((VaultClientOperationsLib.VaultClientFolder)ClientInstance.TreeCache.Repository.Root.Folders[i]).Files[j]
Code: Select all
ClientInstance.GetWorkingFileName(VaultClientFile)
Re: Find vault location for a file under source control.
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.
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
SourceGear
Technical Support Manager
Re: Find vault location for a file under source control.
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.
Re: Find vault location for a file under source control.
Thanks for the update. That's good news. : )
Linda Bauer
SourceGear
Technical Support Manager
SourceGear
Technical Support Manager