示例#1
0
        private void FixupLinksAndSaveParts(string path)
        {
            foreach (PageInfo info in pageIdMap.Values)
            {
                string mhtFile = info.FileName;

                Console.Write("Fixing links " + Path.GetFileName(mhtFile) + "...");
                MimePackage pkg  = MimePackage.Load(mhtFile);
                bool        save = false;

                if (pkg.RootPart.IsHtml)
                {
                    save = FixHtmlLinks(pkg.RootPart);
                }

                if (pkg.Parts != null)
                {
                    foreach (MimePart part in pkg.Parts)
                    {
                        if (part.IsHtml)
                        {
                            save |= FixHtmlLinks(part);
                        }
                    }
                }

                string htm = Path.Combine(path, Path.GetFileNameWithoutExtension(mhtFile) + ".htm");
                pkg.SaveParts(htm, uniqueNames);

                Console.WriteLine("saved");
            }
        }
示例#2
0
        }                                          // if multipart

        public static MimePackage Load(string fileName)
        {
            MimePackage result = new MimePackage();

            using (StreamReader sr = new StreamReader(fileName, Encoding.UTF8))
            {
                result.Parse(sr);
            }

            return(result);
        }