public Stream DownloadQuickFix(string path, bool filtroTipoArtigo = false) { var filenames = _vfs.ListFolderContent(path); using (var zip = new ZipCompression()) { foreach (var filename in filenames) { // HACK 1: ignore article 0 if (filename.Contains("-artigo0-")) { continue; } string basename = GetFilename(filename); using (var file = _vfs.OpenReader(filename)) using (var txtFile = new StreamReader(file)) { var text = txtFile.ReadToEnd(); // HACK 4: filtrar por tipo de artigo if (filtroTipoArtigo && FiltrarTipoArtigo(text)) { continue; } // HACK 2: convert date YYYY_MM_DD to DD/MM/YYYY var newtext = QuickFix2(QuickFix(text)); using (var newstream = new MemoryStream()) { using (var memwrite = new StreamWriter(newstream)) { memwrite.Write(newtext); memwrite.Flush(); newstream.Seek(0, SeekOrigin.Begin); // HACK3: remove "article" from name string newbasename = basename .Replace("-artigo", "") .Replace("DO", "") .Replace("_", ""); int idxP = newbasename.IndexOf("-p"); newbasename = newbasename.Substring(0, idxP); // add XML extension newbasename = newbasename + ".xml"; zip.Add(newbasename, newstream); } } } } return(zip.DownloadStream()); } }
public Stream Download2(string path) { var filenames = _vfs.ListFolderContent(path); using (var zip = new ZipCompression()) { foreach (var filename in filenames) { string basename = GetFilename(filename); using (var file = _vfs.OpenReader(filename)) { zip.Add(basename, file); } } return(zip.DownloadStream()); } }