포함된 파일을 스트림으로 검색
소개
.NET에서 임시 HTTP 서버를 시작하고 index.html만 반환해야 했습니다.
단일의 exe로 완결시키고 싶기 때문에, 이하 2점을 실현하고 싶다고 생각하고 있습니다.
- index.html을 exe에 삽입
- 포함된 리소스를 스트림으로 검색
index.html을 exe에 삽입
index.html의 속성을 열고 빌드 작업을 포함된 리소스로 설정합니다.

포함된 리소스를 스트림으로 검색
GetManifestResourceStream
를 사용하면 스트림으로 포함된 리소스를 검색할 수 있습니다.GetManifestResourceStream
의 인수에는 プロジェクト名.[フォルダ階層.]ファイル名
를 지정합니다.
Program.csvar context = await http.GetContextAsync();
context.Response.ContentType = "text/html";
var assembly = Assembly.GetExecutingAssembly();
using (var file = assembly.GetManifestResourceStream("WindowsFormsApp1.index.html"))
{
file.CopyTo(context.Response.OutputStream);
}
Reference
이 문제에 관하여(포함된 파일을 스트림으로 검색), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/basio/items/8f4287ac8e685c7874a1
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
index.html의 속성을 열고 빌드 작업을 포함된 리소스로 설정합니다.

포함된 리소스를 스트림으로 검색
GetManifestResourceStream
를 사용하면 스트림으로 포함된 리소스를 검색할 수 있습니다.GetManifestResourceStream
의 인수에는 プロジェクト名.[フォルダ階層.]ファイル名
를 지정합니다.
Program.csvar context = await http.GetContextAsync();
context.Response.ContentType = "text/html";
var assembly = Assembly.GetExecutingAssembly();
using (var file = assembly.GetManifestResourceStream("WindowsFormsApp1.index.html"))
{
file.CopyTo(context.Response.OutputStream);
}
Reference
이 문제에 관하여(포함된 파일을 스트림으로 검색), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/basio/items/8f4287ac8e685c7874a1
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
var context = await http.GetContextAsync();
context.Response.ContentType = "text/html";
var assembly = Assembly.GetExecutingAssembly();
using (var file = assembly.GetManifestResourceStream("WindowsFormsApp1.index.html"))
{
file.CopyTo(context.Response.OutputStream);
}
Reference
이 문제에 관하여(포함된 파일을 스트림으로 검색), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/basio/items/8f4287ac8e685c7874a1텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)