Note that there are some explanatory texts on larger screens.

plurals
  1. POUnable to get file type for certain file
    primarykey
    data
    text
    <p>As i am able get Correct file Type for image as JPEG Image. But i can get file type for pdf document or sql file. I am using below code:</p> <pre><code>public String Type { get { return GetType(Path.GetExtension(_document.DocumentPath)); } } public static string ReadDefaultValue(string regKey) { using (var key = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(regKey, false)) { if (key != null) { return key.GetValue("") as string; } } return null; } public string GetType(string ext) { if (ext.StartsWith(".") &amp;&amp; ext.Length &gt; 1) ext = ext.Substring(1); var retVal = ReadDefaultValue(ext + "file"); if (!String.IsNullOrEmpty(retVal)) return retVal; using (var key = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey("." + ext, false)) { if (key == null) return ""; using (var subkey = key.OpenSubKey("OpenWithProgids")) { if (subkey == null) return ""; var names = subkey.GetValueNames(); if (names == null || names.Length == 0) return ""; foreach (var name in names) { retVal = ReadDefaultValue(name); if (!String.IsNullOrEmpty(retVal)) return retVal; } } } return ""; } </code></pre> <p>As i have seen that there is no "OpenWithProgids" subkey in .pdf file in regedit. so what can do to get these file types.</p> <p>For Example In win 7<img src="https://i.stack.imgur.com/IDLWl.png" alt="enter image description here"></p> <p>file type listed with file name and with other information , I want that same file type in my application I am able to xps document but not other document</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload