Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello all,

In my C# code, i have a block of code that does this:

C#
protected bool DownloadLatestVersionFromTFS(string serverURL,
    string serverPath, string localFile, bool setReadOnly)
{
    if (string.IsNullOrEmpty(localFile)
        || string.IsNullOrEmpty(serverURL)
        || string.IsNullOrEmpty(serverPath))
        throw new ArgumentException("Object reference not set to an instance of an object.");
    ICredentialsProvider provider = new UICredentialsProvider();
    using (TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(new Uri(serverURL),
        provider))
    {
        Logger.GetInstance().WriteLog("Connecting to TFS on " + serverURL + "...");
        tfs.Authenticate();
        Logger.GetInstance().WriteLog("Get latest version: " + serverPath + "...");
        VersionControlServer vcs =
            (VersionControlServer)tfs.GetService(typeof(VersionControlServer));
        vcs.DownloadFile(serverPath, localFile);
        if (File.Exists(localFile))
        {
            Logger.GetInstance().WriteLog("Download complete.");
            // set the read-only bit on the downloaded file
            if (setReadOnly==true)
                File.SetAttributes(localFile, FileAttributes.ReadOnly);
            return true;
        }
        else
        {
            Logger.GetInstance().WriteLog("Download failed.");
            return false;
        }
    }


Logger is my own singleton Logger class. Anyway, I run this function in my console application and it works fine on my development machine but then when I deploy it on a remote server with VStudio and TFS installed, it doesn't work, saying

"Item $/MyProject/Folder/MyFile.sql was not found in source control at version T."

Weird...

Am I doing something wrong?

Brian
Posted
Updated 5-Jan-11 12:03pm
v2
Comments
[no name] 5-Jan-11 20:35pm    
What account is this running under? Does it have access to TFS?
Valery Possoz 7-Jan-11 4:10am    
Hello,
- Is there a workspace on the server?
- Is the server workspace bound to a local folder?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900