private void CreateArticleHtml(Article article) { var path = GetPathById[article.Id]; List <Attachment> attachment = (from it in Attachments where it.ArticleId == article.Id select it).ToList(); foreach (var item in attachment) { if (item.ContentType.StartsWith("image")) { Directory.CreateDirectory(path + "\\image"); var imagePath = $".\\image\\{item.Id}-{item.FileName}"; var savePath = $"{path}\\image\\{item.Id}-{item.FileName}"; var replaceString = article.Body.Replace(item.ContentUrl, imagePath); if (!replaceString.Equals(article.Body)) { article.Body = article.Body.Replace(item.ContentUrl, imagePath); ImgFiles.Add(new ImgFile() { Id = item.Id, SourceUrl = item.ContentUrl, DestPath = savePath, IsDownload = false }); } } } HtmlTemplate.CreateArticle(article, GetPathById); }