473,320 Members | 2,112 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,320 software developers and data experts.

getting file icon

hi, how can i get the icon associated with a certain file type? thanks
--
-iwdu15
Sep 21 '06 #1
1 2372
I had this document, it should help you.

How many times have you created your own application and wondered,
"Gee, this thing creates data files--how can I associate my data file
with my application, so that when a user double-click on the data file,
my application starts up and runs it?"

Well, you probably didn't think quite like that, but if you use Word,
you know that if you double-click on a "*.doc" file, Word opens up and
*poof* there's your document.

Introduction
So how do you do that with VB.NET?

There are two ways, the easy way and the hard way. The easy way is best
because if your application gets uninstalled, so will your file
associations. But, you might have occasion to need the hard way. I'll
cover the hard way in a later faq.

Walk Through
The easy way

1. Open up your solution in Visual Studio. If you don't have Visual
Studio, I guess you're out of luck and have to use the hard way.

If you haven't already, add a Setup Project to your solution by File,
Add Project, New Project, Setup & Deployment Projects, Setup Project.

2. Right-click on your setup project in the "Solution Explorer" window,
select "View", then select "File Types".

You'll see the "File Types" window displayed in Visual Studio. At the
top of the window will be "File Types on Target Machine".

3. Right-click on "File Types on Target Machine". The menu will pop up
with "Add File Type" Click on this.

You will see "New Document Type #1" added, with "&Open" underneath it.

4. The "New Document Type #1" can be anything you want--change it to
something descriptive. Although the user never sees this, never use
something common--be as unique as possible, because you can overlay
current file associations without even realizing it. For example, you
might think "pngfile" might be a useful name--but using that will now
send all "*.png" files to your application, instead of to an image
viewer. A good practice may be to use "YourCompanyName.FileType", where
"YourCompanyName" is your name or your company's name, and "FileType"
is a descriptive text of your file.

5. In the "Properties" window for your new type, you will need to
change a few properties:

command: Change to the application you want to run. If you click
on the "...", you will be given your choices, and you will probably
want to locate and use the "Primary Output ..." file.
Description: This is what will show up when your file type is
seen in Windows Explorer.
Extensions: This is your list of extensions to associate with
this file type. You can list any number of extensions, just separate
with a comma, and you don't need to use a period. Avoid, at all costs,
using a common extension (such as ".doc"), because you will overwrite
any pre-existing types!
Icon: This will associate an icon with your file type, that
shows up in Windows Explorer.

6. Are we there yet? Almost--now we move on to that "&Open". This is an
action that is available if your right-click on the file. The default
action ("&Open" is currently set as the default) is what happens when
you double-click on the file. Right-click on your "New Document Type
#1" to add actions, but for the moment, lets define our "&Open" action.
Click on "&Open". You will see in the Properties window "Name",
"Arguments", "Verb". Verb is hidden from the user, but is the key that
is stored in the registry. Leave it the same as the name, but without
the "&". The default for "Arguments" is "%1", which means to pass the
full path and filename to your application. You can add other stuff
here as well, if you need to pass flags to your application to do
special stuff. All this information is getting passed to your
application on the command line, so you'll need to be familiar with the
"Environment.CommandLine" object.
If you need to set a different action as your default, just
right-click on the action and select "Set as Default"

Conclusion
And that's it. Now, when you build your setup project, the file
associations will be included, so that when a user installs your
application, the associations will be installed as well, and if
(hopefully never) the user uninstalls your application, then the
associations will be removed.

Sep 21 '06 #2

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

Similar topics

3
by: Kendall Gifford | last post by:
Greetings. While trying to get a simple app working, I've been forced to delve into embedded and/or linked resources a bit. I read all the reference for the System.Resources namespace as well as...
2
by: Brian Henry | last post by:
I want to list out a directory listing along with showing the file type name (like explorer does when it says something like "MyDoc.DOC - Microsoft Word Document" How do I get that file type name...
3
by: Brian Henry | last post by:
How would you get the associated icon for the file type of a file with a certain extension? like BMP, JPEG, MPEG, etc etc find their default icon using the File Types listing that associates the...
3
by: Brian Henry | last post by:
I have icons which contain 16x16, 24x24, and 32x32 icons in the single file and it is embedded as a resource... I need to get a 16x16 icon only out of it, how would i go about doing that? ive tried...
5
by: IcingDeath via DotNetMonster.com | last post by:
I am building this SQL Server database app in which i can store files. In order to display files I want to have the app show the associated icon for the extension of the file that is in the...
6
by: farseer | last post by:
Hi, I created a new resouce ("app.resx") in my project and added an icon to this resource with name "IL_ICON". I would like to use this resource in some unmanaged code, in particular, with the...
1
by: louismanukonda | last post by:
I'm newbie to xml I have an xml grammer file contain image files, i have to display the contents with an xsl file. The issue is when i mouseover the images i need to display the corresponding...
5
by: Tom | last post by:
I have a main VB.NET application that loads another VB.NET DLL dynamically. Once I have done that, I would like to be able to 'get' the icon of a form in that dynamically loaded DLL. How would...
3
by: UJ | last post by:
I have an icon file stored as part of a program as a resource (Embedded Resource). How can I get the file out of the resource to be able to set a window's icon to the icon? (I know the icon is...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.