我是 SharpSVN 的新手。我从 Internet 上找到了许多与 SharpSVN 相关的示例。我也做了一些成功案例,比如 Checkout
但问题是,我不能调用 commit 和 Add 函数:
我要做的操作是从我的 PC 中选择一个文件,然后添加到指定的 SVN 文件夹,如果文件存在,它应该被复制为新版本。
这是我的代码:
private void button1_Click(object sender, EventArgs e)
{
// FileUpload1.SaveAs("C:\\Users\\user\\Desktop\\crazycodeee\\" + FileUpload1.FileName);
SvnClient client = new SvnClient();
client.Authentication.Clear();
client.Authentication.DefaultCredentials = new NetworkCredential("crazyufuk", "123456");
SvnCheckOutArgs coArgs = new SvnCheckOutArgs();
coArgs.Depth = SvnDepth.Infinity;
// client.CheckOut(new Uri("http://localhost:8080/svn/crazycode/branches/"), "C:\\Users\\TTVERCIN\\Desktop\\crazycodeee");
Add("C:\\Users\\user\\Desktop\\test_folderl\\");
Commit("C:\\Users\\user\\Desktop\\crazycodeee", "AS");
}
public bool Add(string path)
{
using (SvnClient client = new SvnClient())
{
SvnAddArgs args = new SvnAddArgs();
args.Depth = SvnDepth.Empty;
args.AddParents = true;
return client.Add(path, args);
}
}
public bool Commit(string path, string message) //second
{
using (SvnClient client = new SvnClient())
{
SvnCommitArgs args = new SvnCommitArgs();
args.LogMessage = message;
args.ThrowOnError = true;
args.ThrowOnCancel = true;
try
{
return client.Commit(path, args);
}
catch (Exception e)
{
if (e.InnerException != null)
throw new Exception(e.InnerException.Message, e);
throw e;
}
}
}