나는 내 자신의 목적을 위해 고급 html 서버를 작성 중이다. 이제 파일 유형을 지정할 때 문제가 발생했습니다.파일 MIME 형식 가져 오기?
Select Case extension.ToLower()
Case ".avi"
Return "video/x-msvideo"
Case ".css"
Return "text/css"
Case ".doc"
Return "application/msword"
Case ".htm", ".html"
Return "text/html"
...
Case Else
Return "application/octet-stream"
End Select
나는 그런 식으로 그것을 사용 :
Dim context as Net.HttpListenerContext
Dim file as String
context.Response.ContentType = getFileType(Path.GetExtension(file))
나는 또한 C#으로
편집 답변을 받아 들일 : 내 질문 현재 내가 확장
내 기능 코드에 의해 파일 형식을 따지기 어떻게하면 레지스트리와 사건없이 단순히 파일 형식을 얻을 수 있습니까?
그럼 뭐가 궁금한가요? –
이것은 당신에게 유용 할 수 있습니다 : http://stackoverflow.com/questions/11547654/determine-the-file-type-using-c-sharp –
아마도이 [http://msdn.microsoft.com/en- 우리/라이브러리 ...] (http://msdn.microsoft.com/en-us/library/vstudio/y0211exb%28v=vs.100%29.aspx) –