相关疑难解决方法(0)

使用LibGit2Sharp以编程方式删除本地存储库

我想删除使用LibGit2Sharp从远程存储库克隆的本地repo文件夹.我这里读到,我必须在删除它之前Dispose()存储库,但它仍然无法正常工作.

using (var repo = new LibGit2Sharp.Repository(path))
{
    repo.Dispose();
}

Directory.DeleteFolder(path);
Run Code Online (Sandbox Code Playgroud)

我还有一个例外:

Access to the path 'c16566a7-202a-4c8a-84de-3e3caadd5af9' is denied.
Run Code Online (Sandbox Code Playgroud)

'path'变量的内容如下:

 C:\Users\USERNAME\AppData\Local\dftmp\Resources\c16566a7-202a-4c8a-84de-3e3caadd5af9\directory\UserRepos\github.com\domonkosgabor\testrepo
Run Code Online (Sandbox Code Playgroud)

此文件夹由辅助角色创建到本地存储.

我该怎么做才能删除整个文件夹(包括.git)?

c# git github azure-worker-roles libgit2sharp

6
推荐指数
2
解决办法
1847
查看次数

删除git存储库

考虑以下计划:

var path = Path.Combine(
    Path.GetTempPath(),
    Path.GetFileNameWithoutExtension(Path.GetRandomFileName()));
Directory.CreateDirectory(path);

var testFile = Path.Combine(path, "test.txt");
File.WriteAllText(testFile, "Test file");

var source = Repository.Init(path);

using (var repository = new Repository(source))
{
    repository.Index.Add("test.txt");
}

Directory.Delete(path, true); 
Run Code Online (Sandbox Code Playgroud)

在删除存储库文件夹时,我得到了UnauthorizedAccessException- 拒绝访问其中一个内部git文件.为了删除文件夹,还有什么我应该处理的吗?

c# git libgit2sharp

4
推荐指数
1
解决办法
768
查看次数

标签 统计

c# ×2

git ×2

libgit2sharp ×2

azure-worker-roles ×1

github ×1