File Extension and Types

L

Lio

Hi Everybody,

I would like to know how to get the file description from the file URL or
the Extension.

for example:
-----------------------------
in the explorer, there is a file Name column and Type column, if the file is
*.xls in the Type column it will be described as "Microsoft Excel
Worksheet". this is the string i am looking for.
I know you can fine it undr Tools -> Folder Options -> File Types...
-----------------------------
how can i get it from C# code ???

Thanks A lot

Lio
 
R

Rob Teixeira [MVP]

Use the SHGetFileInfo API function (in Shell32.dll)
This function populates an SHFILEINFO structure that contains fields for
both the DisplayName and TypeName of the file.

-Rob Teixeira [MVP]
 
F

Frank Oquendo

Lio said:
how can i get it from C# code ???

Use the Registry classes:

1) Look up the extension in HKCR. If it's registered, you'll find a key
with that extension (e.g. .xls).

2) Read the default value of that key. On my machine, it's
Excel.Worksheet.8.

3)Look for a key with that name in HKCR.

4) Read the default value for that key and you've got the file
description (e.g. "Microsoft Excel Worksheet").

While you're there, you can also determine which icon to show by reading
the default value of the DefaultIcon subkey.


--
There are 10 kinds of people. Those who understand binary and those who
don't.

http://code.acadx.com
(Pull the pin to reply)
 
L

Lio

thanks a lot

I will try it

Lio


Frank Oquendo said:
Use the Registry classes:

1) Look up the extension in HKCR. If it's registered, you'll find a key
with that extension (e.g. .xls).

2) Read the default value of that key. On my machine, it's
Excel.Worksheet.8.

3)Look for a key with that name in HKCR.

4) Read the default value for that key and you've got the file
description (e.g. "Microsoft Excel Worksheet").

While you're there, you can also determine which icon to show by reading
the default value of the DefaultIcon subkey.


--
There are 10 kinds of people. Those who understand binary and those who
don't.

http://code.acadx.com
(Pull the pin to reply)
 
L

Lio

Thanks

as i understand, in order to get this information i have to use the
shell32.dll, to import it to the .net framework.
I will try this option...

thanks again

lio
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top