0
我是SharpSVN的新手。我发现很多互联网上与SharpSVN相关的例子。此外,我做了一些成功的情况下,像结帐SharpSVN无法提交(...不是工作副本)
但问题是,我不能调用commit和添加功能:
,我想要做的就是选择从我的电脑文件的操作,然后添加到指定的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;
}
}
}
除非需要,否则推荐的Subversion API格式不会将最终的'\'添加到路径中。但是,如果您添加它,SharpSvn会为您删除它。 (但是通过通知,列表等获得的路径不会有) – 2012-09-06 17:11:40