Changeset 11660

Show
Ignore:
Timestamp:
02/02/07 16:19:56 (2 years ago)
Author:
vtudoran
Message:

set mimetype from the client side

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • browser-extensions/NXIEHelper/trunk/NxIeHelper2/TransferOperation.cs

    r9498 r11660  
    66using mshtml; 
    77using System.IO; 
     8using Microsoft.Win32; 
    89 
    910namespace NxIEHelperNS 
     
    3738 
    3839                public static TransferOperation crtOperation; 
    39                 public static int crtOpIdx = 0;  
     40                public static int crtOpIdx = 0; 
     41 
     42        public static string GetMimeTypeFromFilename(string fileName) 
     43        { 
     44            int dotPosition = fileName.LastIndexOf('.'); 
     45            if (dotPosition != -1) 
     46            { 
     47                string extension = fileName.Substring( dotPosition ).ToLower(); 
     48                RegistryKey key = Registry.ClassesRoot.OpenSubKey("MIME\\Database\\Content Type"); 
     49 
     50                string[] keyNames = key.GetSubKeyNames(); 
     51                foreach (string keyName in keyNames ) 
     52                { 
     53                    RegistryKey temp = key.OpenSubKey(keyName); 
     54                    if (extension.Equals(temp.GetValue("Extension"))) 
     55                        return keyName; 
     56                } 
     57            } 
     58            return ""; 
     59        } 
    4060                #endregion 
    4161 
     
    220240 
    221241                                string content = sb.ToString(); 
    222                                string mimeType = "application/octet-stream"
     242                string mimeType = GetMimeTypeFromFilename(fileName)
    223243                                //string fileNameNoPath = fileName.Substring(fileName.LastIndexOf(sep) + 1); 
    224244