Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class HtmlFormatter
- {
- /// <summary>
- /// Indicator that this is a URI referencing the local
- /// file path.
- /// </summary>
- public static readonly string FILE_URL_PREFIX =
- "file://";
- /// <summary>
- /// The path separator for HTML paths.
- /// </summary>
- public const string PATH_SEPARATOR = "/";
- }
- // We need to add the proper paths to each image source
- // designation that match where they are being placed on disk.
- String html = HtmlFormatter.ReplaceImagePath(
- myHtml,
- HtmlFormatter.FILE_URL_PREFIX + ApplicationPath.FullAppPath +
- HtmlFormatter.PATH_SEPARATOR);
- <img src="file://ApplicationPath/images/myImage.gif">
- XsltArgumentList lstArgs = new XsltArgumentList();
- lstArgs.AddParam("absoluteRoot", string.Empty, Path.GetFullPath("."));
- <img src="{$absoluteRoot}/Images/SilkIcons/comment_add.gif" align="middle" border="0" />
- html = HtmlFormatter.ReplaceImagePathAuto(html);
- public class HtmlFormatter
- {
- public static readonly string FILE_URL_PREFIX = "file://";
- public static readonly string PATH_SEPARATOR = "/";
- public static String ReplaceImagePath(String html, String path)
- {
- return html.Replace("file://ApplicationPath/", path);
- }
- /// <summary>
- /// Replaces URLs matching file://ApplicationPath/... with Executable Path
- /// </summary>
- /// <param name="html"></param>
- /// <returns></returns>
- public static String ReplaceImagePathAuto(String html)
- {
- String executableName = System.Windows.Forms.Application.ExecutablePath;
- System.IO.FileInfo executableFileInfo = new System.IO.FileInfo(executableName);
- String executableDirectoryName = executableFileInfo.DirectoryName;
- String replaceWith = HtmlFormatter.FILE_URL_PREFIX
- + executableDirectoryName
- + HtmlFormatter.PATH_SEPARATOR;
- return ReplaceImagePath(html, replaceWith);
- }
- }
Add Comment
Please, Sign In to add comment