html을 리소스로 포함시키고 C#에서 외부 브라우저를 사용하여 시작할 수 있습니까? 프로젝트에서이 HTML에 대한 웹 브라우저 컨트롤을 사용하고 싶지 않습니다. 그것은 간단한 도움말 파일입니다. 가능한 한 리소스로 포함하고 싶습니다. 그래서 처리 할 단일 EXE를 가질 수 있습니다.C#에서 외부 브라우저에 포함 된 html을 여는
감사
이 같은html을 리소스로 포함시키고 C#에서 외부 브라우저를 사용하여 시작할 수 있습니까? 프로젝트에서이 HTML에 대한 웹 브라우저 컨트롤을 사용하고 싶지 않습니다. 그것은 간단한 도움말 파일입니다. 가능한 한 리소스로 포함하고 싶습니다. 그래서 처리 할 단일 EXE를 가질 수 있습니다.C#에서 외부 브라우저에 포함 된 html을 여는
감사
이 같은드래그하여 리소스 탭에 자원 html 파일을 드롭 :
var txt = Properties.Resources.sample;
var fileName = Path.ChangeExtension(Path.GetTempFileName(), ".html");
var fs = File.CreateText(fileName);
fs.Write(txt);
fs.Flush();
fs.Close();
Process.Start(fileName);
입니다 :
그런 다음 다음 코드를 사용하여 그것에 대해 ...
public void ExtractFileFromResources(String filename, String location)
{
// Assembly assembly = Assembly.GetExecutingAssembly();
System.Reflection.Assembly a = System.Reflection.Assembly.GetExecutingAssembly();
Stream resFilestream = a.GetManifestResourceStream(filename);
if (resFilestream != null)
{
BinaryReader br = new BinaryReader(resFilestream);
FileStream fs = new FileStream(location, FileMode.Create);
BinaryWriter bw = new BinaryWriter(fs);
byte[] ba = new byte[resFilestream.Length];
resFilestream.Read(ba, 0, ba.Length);
bw.Write(ba);
br.Close();
bw.Close();
resFilestream.Close();
}
}
string path = Path.Combine(System.IO.Path.GetTempPath() + "\file.html");
ExtractFileFromResources("file.html", path);
Process.Start(path);
왜 웹 브라우저 컨트롤을 사용하지 않으시겠습니까? 파일을 외부로 보내지 않으려면 가장 명백한 해결책으로 보입니다. – KingCronus
WinForms 또는 WPF? 이 고양이를 껍질을 벗기는 2 가지 방법이 있기 때문입니다. – code4life
@ Adam. 그냥 더 많은 코드를 추가하고 싶습니다. 더 간단한 방법이 있습니다. – Murlex