public void UseFile(string parentDirectory, Action <string> action) { var tempFileName = CreateFile(parentDirectory); try { action(tempFileName); } catch (Exception e) { _log.Error("unexpected exception while using a temp file", e); } finally { _fileUtil.Delete(tempFileName); } }