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;
}
}
}