Пример #1
0
        /// <summary>
        /// Saves URL to disk as a single HTML file, modified with absolute external references
        /// if a folder is provided instead of a filename, the TITLE tag is used to name the file
        /// </summary>
        /// <param name="outputFilePath">path to generate to, or filename to generate</param>
        /// <param name="url">fully qualified URL you wish to save</param>
        /// <returns>the complete path of the HTML file that was saved to disk</returns>
        public string SavePage(String outputFilePath, params String[] url)
        {
            String URL = String.Empty;

            if (url.Length > 0)
            {
                URL = url[0];
            }


            ValidateFilename(outputFilePath, ".htm;.html");

            if (URL != null)
            {
                DownloadHtmlFile(URL);
            }

            _HtmlFile.UseHtmlTitleAsFilename = true;
            _HtmlFile.DownloadPath           = outputFilePath;
            _HtmlFile.SaveToFile();

            return(_HtmlFile.DownloadPath);
        }
Пример #2
0
        /// <summary>
        /// Saves URL to disk as multiple files: a single HTML file, modified with local references
        /// to externally referenced files in a subfolder
        /// if a folder is provided instead of a filename, the TITLE tag is used to name the file
        /// </summary>
        /// <param name="outputFilePath">path to generate to, or filename to generate</param>
        /// <param name="url">fully qualified URL you wish to save</param>
        /// <returns>the complete path of the HTML file that was saved to disk</returns>
        public string SavePageComplete(string outputFilePath, params String[] url)
        {
            String URL = String.Empty;

            if (url.Length > 0)
            {
                URL = url[0];
            }

            ValidateFilename(outputFilePath, ".htm;.html");

            if (URL != null)
            {
                DownloadHtmlFile(URL);
            }


            //-- first, let's get all the external files
            _HtmlFile.DownloadPath           = outputFilePath;
            _HtmlFile.UseHtmlTitleAsFilename = true;
            _HtmlFile.DownloadExternalFiles(FileStorage.DiskPermanent, _AllowRecursion);

            //-- convert any references in external files
            foreach (DictionaryEntry de in WebFiles)
            {
                WebFile ef = (WebFile)de.Value;
                if (ef.IsHtml | ef.IsCss)
                {
                    ef.ConvertReferencesToLocal();
                    ef.SaveToFile();
                }
            }

            //-- convert the main HTML references
            _HtmlFile.ConvertReferencesToLocal();
            _HtmlFile.SaveToFile();

            return(_HtmlFile.DownloadPath);
        }