public string WriteToFile(string filename, List <string> listContent) { var pathToWrite = filename; if (_fileReader.Exists(pathToWrite)) { var ext = Path.GetExtension(pathToWrite); var file = Path.GetFileNameWithoutExtension(pathToWrite); pathToWrite = $"{file}_{DateTime.Now.Ticks.ToString()}{ext}"; } using (var streamToWrite = _streamService.GetStreamFromList(listContent)) { _fileWriter.WriteToFile(pathToWrite, streamToWrite); } return(pathToWrite); }