473,396 Members | 1,871 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

File Extension and Types

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

Nov 15 '05 #1
4 3834
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]

"Lio" <am****@zahav.net.il> wrote in message
news:eg**************@TK2MSFTNGP09.phx.gbl...
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

Nov 15 '05 #2
Lio wrote:
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)
Nov 15 '05 #3
Lio
thanks a lot

I will try it

Lio
"Frank Oquendo" <fr*******@acadx.com> wrote in message
news:uH**************@TK2MSFTNGP09.phx.gbl...
Lio wrote:
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)

Nov 15 '05 #4
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
"Rob Teixeira [MVP]" <RobTeixeira@@msn.com> wrote in message
news:%2******************@TK2MSFTNGP11.phx.gbl...
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]

"Lio" <am****@zahav.net.il> wrote in message
news:eg**************@TK2MSFTNGP09.phx.gbl...
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


Nov 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: David Allison | last post by:
I am looking to open my MDE Application using the DB files associated with the application I have created. My application is using a non descript three digit extension that is related to the...
0
by: Gabest | last post by:
One of my users seems to have found a kind of bug (?, but certainly an annoyance) in the implementation of the standard file dialog box of windows for saving. When the "hide externsion for known...
3
by: Nate Hekman | last post by:
I have an aspx page that generates a file on the fly for a person to download. It sends these http headers: Content-Type: text/plain Content-Disposition: attachment; filename="myfile.lic" ...
3
by: Shapper | last post by:
Hello, I created a script to upload a file. To determine the file type I am using userPostedFile.ContentType. For example, for a png image I get "image/png". My questions are: 1. Where can...
0
by: troutbum | last post by:
I am experiencing problems when one user has a document open through a share pointing to the web site. I use the dsolefile to read the contents of a particular directory and then display them in a...
0
by: robert | last post by:
Hi all, I'm having a hard time resolving a namespace issue in my wsdl. Here's an element that explains my question, with the full wsdl below: <definitions name="MaragatoService"...
3
by: Phoe6 | last post by:
Hi all, I had a filesystem crash and when I retrieved the data back the files had random names without extension. I decided to write a script to determine the file extension and create a newfile...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
0
by: rautsmita | last post by:
hello friends , i am using to jdk6 and JAXB2.0, i have geomtry.xsd file i am trying to compile this file using jaxb but i got some error i.e.The particle of the type is not a valid restriction of...
6
by: David B. | last post by:
Using Win XP SP2 I wrote up a XHTML file using notepad. Now I want my browser to open it as a web page but it only sees it as a .txt file. I tried changing the extension to .htm but its still a...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.