tags:

views:

20

answers:

2

When I try to download a file from TFS version control SDK to my computer I receive an 'UnauthorizedAccessException' saying Access to the local path I'm trying to download to is denied. I included a stripped down version of the code I am using below.

var projectCollection = GetProjectCollection();
var versionControl = (VersionControlServer)projectCollection.GetService(typeof(VersionControlServer));
versionControl.DownloadFile('$/path to file', 'local path to download to');

Does anyone know how to resolve this issue?

A: 

This is because the process does not have rights to the local path. Make sure the local path has the appropriate right set to the user that is running the process.

Robaticus
I checked and it does have rights
Paul
A: 

I found the issue.

The second argument in DownloadFile() needs to be the file name it will be downloaded as and not the parent directory it will be placed in. I thought it just needed the directory name.

So instead of what I originally had

versionControl.DownloadFile("$/Readme.txt", "C:\\Temp");

it needs to be

versionControl.DownloadFile("$/Readme.txt", "C:\\Temp\\Readme.txt");
Paul