private void WriteLogs(DefaultLogger l) { foreach (KeyValuePair <string, List <ImportRow> > kvp in l.GetLogRecords()) { string logPath = string.Format(@"{0}sitecore modules\Shell\Data Import\logs\{1}.{2}.{3}.csv", HttpRuntime.AppDomainAppPath, importItem.DisplayName.Replace(" ", "-"), DateTime.Now.ToString("yyyy.MM.dd.H.mm.ss"), kvp.Key); var file = File.CreateText(logPath); var csvFile = new CsvWriter(file); csvFile.WriteHeader <ImportRow>(); foreach (ImportRow ir in kvp.Value) { csvFile.WriteRecord(ir); } file.Close(); } }