public async Task <bool> RecycleAsync(string filePath, bool suppressDialogs = false) { try { await Task.Run(() => { if (suppressDialogs) { _fileSystem.DeleteFile(filePath, UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin); } else { _fileSystem.DeleteFile(filePath, UIOption.AllDialogs, RecycleOption.SendToRecycleBin); } }); return(true); } catch (FileNotFoundException fileNotFoundEx) { _logger.Warn(fileNotFoundEx); return(true); } catch (OperationCanceledException cancelledEx) { _logger.Warn(cancelledEx, "The user cancelled the operation."); return(false); } }
public void CleanupContext(TestContext context) { if (context == null) { throw new ArgumentNullException("context"); } foreach (var file in context.TemporaryFiles) { try { fileSystem.DeleteFile(file); } catch (IOException) { // Supress exception } } }