【发布时间】:2014-10-22 08:41:52
【问题描述】:
我想删除使用 LibGit2Sharp 从远程存储库克隆的本地存储库文件夹。 我在这里读到here,我必须先 Dispose() 存储库才能删除它,但它仍然不能正常工作。
using (var repo = new LibGit2Sharp.Repository(path))
{
repo.Dispose();
}
Directory.DeleteFolder(path);
我还有一个例外:
Access to the path 'c16566a7-202a-4c8a-84de-3e3caadd5af9' is denied.
'path'变量的内容如下:
C:\Users\USERNAME\AppData\Local\dftmp\Resources\c16566a7-202a-4c8a-84de-3e3caadd5af9\directory\UserRepos\github.com\domonkosgabor\testrepo
此文件夹由工作人员角色创建到本地存储。
我应该怎么做才能删除整个文件夹(包括.git)?
【问题讨论】:
-
您的
path文件夹有一个 Guid,而不是文件夹路径。它来自哪里?还有,I read here that I have to Dispose()这里在哪里?忘记链接了吗? -
我在问题中添加了更多信息。
-
两件事:1) 您是否以足够的权限执行此代码(即作为管理员?) 2) 在
DeleteFolder代码之前添加代码if (Directory.Exists(path))以确保目录确实存在.
标签: c# git github azure-worker-roles libgit2sharp