Svn force export using c#

1.1k views Asked by At

I am trying to export files or folders from SVN using c#. I used the SharpSvn lib.

SharpSvn.SvnClient svnclient = new SvnClient();
svnclient.Export(new SvnUriTarget(source), target, new SvnExportArgs());

I have been trying to export the source to directory. It is successful(If folder doesn't exists)

But If the folder exists it throws the following error

SharpSvn.SvnObstructedUpdateException: 'E:\abc\SVN\SVNtest' already exists

In the command line,

svn --force export

will work

but for C#, what is the class or method I have to use to overwrite the existing folder.

I don't want to call any bat file or vbscript because I want to handle all the errors or exceptions in c# only.

1

There are 1 answers

2
alroc On BEST ANSWER

The documentation is a bit thin, but have you looked at the Overwrite property of SVNExportArgs?

SharpSvn.SvnClient svnclient = new SvnClient();
SvnExportArgs ex = new SvnExportArgs();
ex.Overwrite = true;
svnclient.Export(new SvnUriTarget(source), target, ex);

I haven't tested this, so I may be completely off the mark, but it seems logical.