下载SharpSvn 1.8
在工程里引用其中的 SharpSvn.dll
Update
public static void SvnDownload()
{
using (SvnClient client = new SvnClient())
{
//client.Authentication.Clear();
client.Authentication.UserNamePasswordHandlers += new EventHandler<SharpSvn.Security.SvnUserNamePasswordEventArgs>(
delegate (Object s, SharpSvn.Security.SvnUserNamePasswordEventArgs ee)
{
ee.UserName = "abc";
ee.Password = "defg";
});
client.Authentication.SslServerTrustHandlers += new EventHandler<SharpSvn.Security.SvnSslServerTrustEventArgs>(
delegate (Object ssender, SharpSvn.Security.SvnSslServerTrustEventArgs se)
{
// Look at the rest of the arguments of E whether you wish to accept
// If accept:
se.AcceptedFailures = se.Failures;
se.Save = true; // Save acceptance to authentication store
});
Console.WriteLine(client.CheckOut(
new Uri("d:\\svn\temp\test.txt"),
@"C:\Users\nhuang\Desktop\hi"));
}
}
Commit(上面登录的代码就不重复了)
using (SvnClient client = new SvnClient())
{
SvnCommitArgs commitArgs = new SvnCommitArgs();
commitArgs.Depth = SvnDepth.Empty;
commitArgs.LogMessage = "My Test Commit";
SvnCommitResult commitResult = null;
client.Commit(@"d:\\svn\temp\test.txt", commitArgs, out commitResult);
}
获取日志
using (SvnClient client = new SvnClient())
{
StringBuilder strBuilder = new StringBuilder();
SvnClientReporter reporter = new SvnClientReporter(client, strBuilder);
}
取消操作
using (SvnClient client = new SvnClient())
{
//do something
client.Cancel +=
delegate (object s, SvnCancelEventArgs e)
{
e.Cancel = true;
};
//do svn Operations
}