Gecko Webbrowser - Quelltext in Notepad++, beziehungsweiße in Notepad anzeigen lassen, wenn kein Notepad++ vorhanden ist.
usings:
using System.Windows.Forms;
using System.IO;
using System;
using Gecko;
Ich verwende:
GeckoFx 33.0
Xulrunner 33.1
// View browser source in notepad++ or in notepad
private void geckoGetSourceToNotepad(object sender, EventArgs e)
{
var source = geckoWebBrowser1.Document.GetElementsByTagName("html")[0].InnerHtml.ToString();
var path = Application.StartupPath + "\\SourceCode.txt";
using (StreamWriter sw = new StreamWriter(path))
sw.Write(source);
try
{
var editor = "notepad++.exe";
System.Diagnostics.Process.Start(editor, path);
}
catch
{
var editor = "notepad.exe";
System.Diagnostics.Process.Start(editor, path);
}
}
Kommentare zum Snippet