Sprache: C#
Gecko Webbrowser – Quelltext in Notepad++, beziehungsweiße in Notepad anzeigen lassen, wenn kein Notepad++ vorhanden ist.
[u]usings:[/u]
using System.Windows.Forms;
using System.IO;
using System;
using Gecko;
[u]Ich verwende:[/u]
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);
}
}
// 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);
}
}
Alte URL:
/snippet/geckofx-quelltext-im-editor-anzeigen-lassen/15172