本文整理汇总了C#中IFileSystem.DeleteDirectory方法的典型用法代码示例。如果您正苦于以下问题:C# IFileSystem.DeleteDirectory方法的具体用法?C# IFileSystem.DeleteDirectory怎么用?C# IFileSystem.DeleteDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IFileSystem
的用法示例。
在下文中一共展示了IFileSystem.DeleteDirectory方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PerformDirectoryDeletionOperation
/// <summary>
/// Performs a directory deletion.
/// </summary>
/// <param name="fileSystem">The file system.</param>
/// <param name="directory">The directory to delete.</param>
/// <param name="execute">if set to true, the operation gets executed.</param>
private void PerformDirectoryDeletionOperation(IFileSystem fileSystem, IDirectoryInfo directory, bool execute)
{
var eventArgs = new DirectoryDeletionEventArgs(directory.FullName);
this.OnDeletingDirectory(eventArgs);
var directoryScanner = new FileSystemScanner(directory);
directoryScanner.FileFound += (sender, e) =>
this.OnProceededFile(new FileProceededEventArgs(e.File.FullName, e.File.Length));
directoryScanner.Start();
if (execute)
{
try
{
fileSystem.DeleteDirectory(directory);
this.OnDeletedDirectory(eventArgs);
}
catch (AccessException)
{
this.OnDirectoryDeletionError(new DirectoryDeletionEventArgs(directory.FullName));
}
}
}
示例2: Clean
public void Clean(IFileSystem fileSystem, CleanMode mode)
{
if (mode == CleanMode.all || mode == CleanMode.packages)
{
var packagesFolder = PackagesFolder();
Console.WriteLine("Deleting " + packagesFolder);
fileSystem.DeleteDirectory(packagesFolder);
}
if (mode == CleanMode.all || mode == CleanMode.projects)
{
_projects.Each(p => p.Clean(fileSystem));
}
}
示例3: DeleteTempTestDir
private static string DeleteTempTestDir(IFileSystem fileSystem)
{
if (fileSystem.DirectoryExists(TestConstants.TempDirectory)) {
fileSystem.DeleteDirectory(TestConstants.TempDirectory);
}
return TestConstants.TempDirectory;
}
示例4: Close
public static void Close(IFileSystem fileSystem) {
var folder = GetTempCsvFilesFolder();
if (fileSystem.DirectoryExists(folder)) {
// Note: some files may still be locked if they are opened in Excel
try {
fileSystem.DeleteDirectory(folder, recursive: true);
} catch (IOException) { } catch (UnauthorizedAccessException) { }
}
}