2017-12-19 23 views
2

Mime Type을 코드에 저장하려고합니다. 지금은이 작업을 수행하는 데 사용 :C# Mime Types 클래스

string mYMimeType = "text/plain"; 

A (이미 존재) 표준에 저장하는 방법은 전용 클래스가 있습니까? 당신이 사용 MediaTypeNames 클래스의 수

Http.MimeTypes myMimeType = Http.MimeTypes.TextPlain; 

답변

3

뭔가 등 ... System.Net.Mime namesapce에 존재합니다.

다음은 .net 클래스가 도움이 될 수 있습니다. 직접 만들지 않아도됩니다.

namespace System.Net.Mime 
{ 
    // Summary: 
    //  Specifies the media type information for an e-mail message attachment. 
    public static class MediaTypeNames 
    { 

     // Summary: 
     //  Specifies the kind of application data in an e-mail message attachment. 
     public static class Application 
     { 
      // Summary: 
      //  Specifies that the System.Net.Mime.MediaTypeNames.Application data is not 
      //  interpreted. 
      public const string Octet = "application/octet-stream"; 
      // 
      // Summary: 
      //  Specifies that the System.Net.Mime.MediaTypeNames.Application data is in 
      //  Portable Document Format (PDF). 
      public const string Pdf = "application/pdf"; 
      // 
      // Summary: 
      //  Specifies that the System.Net.Mime.MediaTypeNames.Application data is in 
      //  Rich Text Format (RTF). 
      public const string Rtf = "application/rtf"; 
      // 
      // Summary: 
      //  Specifies that the System.Net.Mime.MediaTypeNames.Application data is a SOAP 
      //  document. 
      public const string Soap = "application/soap+xml"; 
      // 
      // Summary: 
      //  Specifies that the System.Net.Mime.MediaTypeNames.Application data is compressed. 
      public const string Zip = "application/zip"; 
     } 

     // Summary: 
     //  Specifies the type of image data in an e-mail message attachment. 
     public static class Image 
     { 
      // Summary: 
      //  Specifies that the System.Net.Mime.MediaTypeNames.Image data is in Graphics 
      //  Interchange Format (GIF). 
      public const string Gif = "image/gif"; 
      // 
      // Summary: 
      //  Specifies that the System.Net.Mime.MediaTypeNames.Image data is in Joint 
      //  Photographic Experts Group (JPEG) format. 
      public const string Jpeg = "image/jpeg"; 
      // 
      // Summary: 
      //  Specifies that the System.Net.Mime.MediaTypeNames.Image data is in Tagged 
      //  Image File Format (TIFF). 
      public const string Tiff = "image/tiff"; 
     } 

     // Summary: 
     //  Specifies the type of text data in an e-mail message attachment. 
     public static class Text 
     { 
      // Summary: 
      //  Specifies that the System.Net.Mime.MediaTypeNames.Text data is in HTML format. 
      public const string Html = "text/html"; 
      // 
      // Summary: 
      //  Specifies that the System.Net.Mime.MediaTypeNames.Text data is in plain text 
      //  format. 
      public const string Plain = "text/plain"; 
      // 
      // Summary: 
      //  Specifies that the System.Net.Mime.MediaTypeNames.Text data is in Rich Text 
      //  Format (RTF). 
      public const string RichText = "text/richtext"; 
      // 
      // Summary: 
      //  Specifies that the System.Net.Mime.MediaTypeNames.Text data is in XML format. 
      public const string Xml = "text/xml"; 
     } 
    } 
} 
+1

왜 .net과 같은 표준에는 일부 mediatype이 없지만 소수입니까? 나는 이해할 수 없다 :-) 그러나, 답장을 보내 주셔서 감사합니다. – Alex