public async Task <IHttpActionResult> Delete(string file) { if (string.IsNullOrEmpty(file)) { return(BadRequest()); } try { SetCredentials(); if (await ftpClient.DeleteFileAsync(file)) { return(Ok()); } else { return(NotFound()); } } catch { return(InternalServerError()); } }
public async Task RemoveAsync(string Path, string Filename) { try { if (_ftpClient.DirectoryExists(Path)) { _ftpClient.RetryAttempts = 10; string fullpath = Path + Filename; _log.Info($"{FtpTemplateMessage("Remove", Filename)}", fullpath); await _ftpClient.DeleteFileAsync(fullpath); } else { _log.Info($"{FtpTemplateMessage("Remove", Filename, "not exist")}", Path + Filename); throw new Exception("File Not Exist"); } } catch (Exception ex) { _log.Error($"{FtpTemplateMessage("Remove", Filename, "throw exception")}", ex); throw ex; } }
public async Task Delete(string fileName) { await _EnsureConnection(); await _ftpClient.DeleteFileAsync($"/{PathHelper.Combine(_options.Path, fileName)}"); }