Search code examples
sharpsvnvcs-checkout

How to checkout a file using sharpsvn


I tried to checkout a file using sharpsvn from remote repository,but i found sharpsvn can not to checkout single file only checkout folder,please help me to know how to checkout a file?Thx. My code

SvnUpdateResult result;
        SvnCheckOutArgs checkoutArgs = new SvnCheckOutArgs();
        string target = txtRepository.Text.Trim();
        SvnUriTarget url = new SvnUriTarget(target);
        string fileName = url.FileName;

        string path = folder + "\\" + fileName;
        using (SvnClient client = new SvnClient())
        {
            try
            {
                client.CheckOut(url,txtLocalFilePath.Text.Trim(),out result);//.Update(path,updateArgs,out result);
                if (result != null)
                {
                    WriteCheckOutTime(txtRepository.Text.Trim(), result.Revision);
                    MessageBox.Show("Check out success!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

            }
            catch (SvnException svnException)
            {
                MessageBox.Show(svnException.Message + "Check out error!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            catch (UriFormatException uriException)
            {
                MessageBox.Show(uriException.Message + "Check out error!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }

Solution

  • The smallest element you can check out with Subversion is a directory. It is not possible to check out a single file.

    You can check out a directory, but leave it empty, via the Sparse Directories feature. Then update only the file you're interested in. But you must start with a directory.