By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,947 Members | 1,548 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,947 IT Pros & Developers. It's quick & easy.

Change Folder Icon Programmatically

P: n/a
Hi,
I can change the icon for a folder by right clicking on it > going to the
customize tab > and selecting Choose Picture.
Does anyone know if it is possible to do this programmatically from a
windows forms application?
Thanks
Phil
Nov 21 '05 #1
Share this Question
Share on Google+
16 Replies


P: n/a
Phil Hey wrote:
Hi,
I can change the icon for a folder by right clicking on it > going to the
customize tab > and selecting Choose Picture.
Does anyone know if it is possible to do this programmatically from a
windows forms application?
Thanks
Phil


Maybe if you change the registry entry at:
hkey_classes_root\folder\DefaultIcon

That where I think the icon definition is stored.
--
Rinze van Huizen
C-Services Holland b.v.
Nov 21 '05 #2

P: n/a
Phil Hey wrote:
Hi,
I can change the icon for a folder by right clicking on it > going to the
customize tab > and selecting Choose Picture.
Does anyone know if it is possible to do this programmatically from a
windows forms application?
Thanks
Phil


Maybe if you change the registry entry at:
hkey_classes_root\folder\DefaultIcon

That where I think the icon definition is stored.
--
Rinze van Huizen
C-Services Holland b.v.
Nov 21 '05 #3

P: n/a
> Maybe if you change the registry entry at:
hkey_classes_root\folder\DefaultIcon

That where I think the icon definition is stored.
--

Yes, but I dont want to change all the folders just certain ones, thanks
anyway

Phil
Nov 21 '05 #4

P: n/a
> Maybe if you change the registry entry at:
hkey_classes_root\folder\DefaultIcon

That where I think the icon definition is stored.
--

Yes, but I dont want to change all the folders just certain ones, thanks
anyway

Phil
Nov 21 '05 #5

P: n/a
Phil Hey wrote:
Maybe if you change the registry entry at:
hkey_classes_root\folder\DefaultIcon

That where I think the icon definition is stored.
--


Yes, but I dont want to change all the folders just certain ones, thanks
anyway

Phil

I don't think you can since Windows displays the icons according to
filetype. A folder is just a folder to Windows. So it will look up the
icon there and display it. Just like you can't display icon A for one
textfile(.txt) and icon B for another textfile(.txt). So unless you make
a shortcut and change the icon of that I can't see a way.

I might be wrong though, in that case I would love to see how it's done :)
--
Rinze van Huizen
C-Services Holland b.v.
Nov 21 '05 #6

P: n/a
Phil Hey wrote:
Maybe if you change the registry entry at:
hkey_classes_root\folder\DefaultIcon

That where I think the icon definition is stored.
--


Yes, but I dont want to change all the folders just certain ones, thanks
anyway

Phil

I don't think you can since Windows displays the icons according to
filetype. A folder is just a folder to Windows. So it will look up the
icon there and display it. Just like you can't display icon A for one
textfile(.txt) and icon B for another textfile(.txt). So unless you make
a shortcut and change the icon of that I can't see a way.

I might be wrong though, in that case I would love to see how it's done :)
--
Rinze van Huizen
C-Services Holland b.v.
Nov 21 '05 #7

P: n/a
Phil Hey wrote:
I can change the icon for a folder by right clicking on it > going to the
customize tab > and selecting Choose Picture.


I think if you have an image inside the folder called folder.jpg Windows
will automatically use this for the folder image. You could copy this in
in your code. Not sure if this helps at all.
Nov 21 '05 #8

P: n/a
Phil Hey wrote:
I can change the icon for a folder by right clicking on it > going to the
customize tab > and selecting Choose Picture.


I think if you have an image inside the folder called folder.jpg Windows
will automatically use this for the folder image. You could copy this in
in your code. Not sure if this helps at all.
Nov 21 '05 #9

P: n/a
Rinze Wrote:
I don't think you can since Windows displays the icons according to
filetype.
You can definatelly do this (manually at least) for individual folders
rather than all folders as i am looking at an example of this now. Maybe if
I explain the situation it will help:

I have a drive on the server called Jobs (j:) in this drive I have folders
for each of the jobs lablled 'J1194' for example. When, in my application, a
job is made in-active i want this folder to appear with a red cross through
it to in dicate that it is closed.

elzico wrote: I think if you have an image inside the folder called folder.jpg Windows
will automatically use this for the folder image. You could copy this in
in your code. Not sure if this helps at all.


Ok, I have tried this and it works but only if you are viewing the folders
in Thumbnail view not in any of the other views.

Anyway thanks for the help

Phil

Nov 21 '05 #10

P: n/a
Rinze Wrote:
I don't think you can since Windows displays the icons according to
filetype.
You can definatelly do this (manually at least) for individual folders
rather than all folders as i am looking at an example of this now. Maybe if
I explain the situation it will help:

I have a drive on the server called Jobs (j:) in this drive I have folders
for each of the jobs lablled 'J1194' for example. When, in my application, a
job is made in-active i want this folder to appear with a red cross through
it to in dicate that it is closed.

elzico wrote: I think if you have an image inside the folder called folder.jpg Windows
will automatically use this for the folder image. You could copy this in
in your code. Not sure if this helps at all.


Ok, I have tried this and it works but only if you are viewing the folders
in Thumbnail view not in any of the other views.

Anyway thanks for the help

Phil

Nov 21 '05 #11

P: n/a
Hi Phil

For the Thumbnails view, you should get a picture showing automatically. If
you set an icon for other views, then you get a Desktop.ini file created in
the folder, with this as the content:

[.ShellClassInfo]
IconFile=%SystemRoot%\system32\SHELL32.dll
IconIndex=21

This code creates the file and works...cool!

Dim fs As New IO.FileStream("C:\Test\Desktop.ini", IO.FileMode.Create)
Dim tw As New IO.StreamWriter(fs)
tw.WriteLine("[.ShellClassInfo]")
tw.WriteLine("IconFile=%SystemRoot%\system32\SHELL 32.dll")
tw.WriteLine("IconIndex = 21")
tw.Close()
fs.Close()

HTH

Nigel
"Phil Hey" wrote:
Hi,
I can change the icon for a folder by right clicking on it > going to the
customize tab > and selecting Choose Picture.
Does anyone know if it is possible to do this programmatically from a
windows forms application?
Thanks
Phil

Nov 21 '05 #12

P: n/a
Hi Phil

For the Thumbnails view, you should get a picture showing automatically. If
you set an icon for other views, then you get a Desktop.ini file created in
the folder, with this as the content:

[.ShellClassInfo]
IconFile=%SystemRoot%\system32\SHELL32.dll
IconIndex=21

This code creates the file and works...cool!

Dim fs As New IO.FileStream("C:\Test\Desktop.ini", IO.FileMode.Create)
Dim tw As New IO.StreamWriter(fs)
tw.WriteLine("[.ShellClassInfo]")
tw.WriteLine("IconFile=%SystemRoot%\system32\SHELL 32.dll")
tw.WriteLine("IconIndex = 21")
tw.Close()
fs.Close()

HTH

Nigel
"Phil Hey" wrote:
Hi,
I can change the icon for a folder by right clicking on it > going to the
customize tab > and selecting Choose Picture.
Does anyone know if it is possible to do this programmatically from a
windows forms application?
Thanks
Phil

Nov 21 '05 #13

P: n/a

Phil Hey wrote:

You can definatelly do this (manually at least) for individual folders
rather than all folders as i am looking at an example of this now. Maybe if
I explain the situation it will help:

I have a drive on the server called Jobs (j:) in this drive I have folders
for each of the jobs lablled 'J1194' for example. When, in my application, a
job is made in-active i want this folder to appear with a red cross through
it to in dicate that it is closed.


That may be something XP specific I think. On this Win98 computer I
can't change the icon for a specific folder. But elzico might be on to
something.

--
Rinze van Huizen
C-Services Holland b.v.
Nov 21 '05 #14

P: n/a

Phil Hey wrote:

You can definatelly do this (manually at least) for individual folders
rather than all folders as i am looking at an example of this now. Maybe if
I explain the situation it will help:

I have a drive on the server called Jobs (j:) in this drive I have folders
for each of the jobs lablled 'J1194' for example. When, in my application, a
job is made in-active i want this folder to appear with a red cross through
it to in dicate that it is closed.


That may be something XP specific I think. On this Win98 computer I
can't change the icon for a specific folder. But elzico might be on to
something.

--
Rinze van Huizen
C-Services Holland b.v.
Nov 21 '05 #15

P: n/a
Nigel you are an absolute legend, thanks. :-)

One thing of note is that the folder must be a system folder (whatever that
means). Here is a link to a knowledge base article with some info :

http://msdn.microsoft.com/library/de...ing/custom.asp

Phil

"Nigel Armstrong" <Ni************@discussions.microsoft.com> wrote in
message news:CD**********************************@microsof t.com...
Hi Phil

For the Thumbnails view, you should get a picture showing automatically.
If
you set an icon for other views, then you get a Desktop.ini file created
in
the folder, with this as the content:

[.ShellClassInfo]
IconFile=%SystemRoot%\system32\SHELL32.dll
IconIndex=21

This code creates the file and works...cool!

Dim fs As New IO.FileStream("C:\Test\Desktop.ini",
IO.FileMode.Create)
Dim tw As New IO.StreamWriter(fs)
tw.WriteLine("[.ShellClassInfo]")
tw.WriteLine("IconFile=%SystemRoot%\system32\SHELL 32.dll")
tw.WriteLine("IconIndex = 21")
tw.Close()
fs.Close()

HTH

Nigel
"Phil Hey" wrote:
Hi,
I can change the icon for a folder by right clicking on it > going to the
customize tab > and selecting Choose Picture.
Does anyone know if it is possible to do this programmatically from a
windows forms application?
Thanks
Phil

Nov 21 '05 #16

P: n/a
Nigel you are an absolute legend, thanks. :-)

One thing of note is that the folder must be a system folder (whatever that
means). Here is a link to a knowledge base article with some info :

http://msdn.microsoft.com/library/de...ing/custom.asp

Phil

"Nigel Armstrong" <Ni************@discussions.microsoft.com> wrote in
message news:CD**********************************@microsof t.com...
Hi Phil

For the Thumbnails view, you should get a picture showing automatically.
If
you set an icon for other views, then you get a Desktop.ini file created
in
the folder, with this as the content:

[.ShellClassInfo]
IconFile=%SystemRoot%\system32\SHELL32.dll
IconIndex=21

This code creates the file and works...cool!

Dim fs As New IO.FileStream("C:\Test\Desktop.ini",
IO.FileMode.Create)
Dim tw As New IO.StreamWriter(fs)
tw.WriteLine("[.ShellClassInfo]")
tw.WriteLine("IconFile=%SystemRoot%\system32\SHELL 32.dll")
tw.WriteLine("IconIndex = 21")
tw.Close()
fs.Close()

HTH

Nigel
"Phil Hey" wrote:
Hi,
I can change the icon for a folder by right clicking on it > going to the
customize tab > and selecting Choose Picture.
Does anyone know if it is possible to do this programmatically from a
windows forms application?
Thanks
Phil

Nov 21 '05 #17

This discussion thread is closed

Replies have been disabled for this discussion.