0
我在使用sharpsvn提交时遇到问题。现在我添加我的工作副本的所有文件(如果文件被添加引发异常),并且在它之后我提交。它可以工作,但会导致异常。在添加()之前有一些方法可以获取存储库的状态,并且只添加新文件或更改的文件?如果我删除我的工作副本上的一个文件或文件夹,如何删除这些文件或资料库上的文件夹? 代码:提交sharpSVN
String[] folders;
folders = Directory.GetDirectories(direccionLocal,"*.*", SearchOption.AllDirectories);
foreach (String folder in folders)
{
String[] files;
files = Directory.GetFiles(folder);
foreach (String file in files)
{
if (file.IndexOf("\\.svn") == -1)
{
Add(file, workingcopy);
}
}
}
Commit(workingcopy, "change");
地址:
public bool Add(string path, string direccionlocal)
{
using (SvnClient client = new SvnClient())
{
SvnAddArgs args = new SvnAddArgs();
args.Depth = SvnDepth.Empty;
Console.Out.WriteLine(path);
args.AddParents = true;
try
{
return client.Add(path, args);
}
catch (Exception ex)
{
return false;
}
}
}
提交:
public bool Commit(string path, string message)
{
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;
}
}
}