Click here to Skip to main content
15,906,558 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
I want to name all the shortcuts in the program folder in the write to combobox

What I have tried:

I want to name all the shortcuts in the program folder in the write to combobox
Posted
Updated 7-Jun-19 20:00pm
Comments
Patrice T 7-Jun-19 18:31pm    
And you have a question ?
BillWoodruff 7-Jun-19 22:37pm    
Show us the code you use now.
Dave Kreskowiak 7-Jun-19 23:27pm    
You're going to have to do a much better job of explaining what you want to do and what problem you're having.

1 solution

If you mean you want to list all of the shortcut files in a folder, then that's trivial:
C#
string[] files = Directory.GetFiles(@"C:\Users\PaulG\Desktop\Utilities", "*.lnk");
Then all you have to do is display them:
C#
myComboBox.Items.AddRange(files);
If that isn't what you are having difficulty with, then you need to be a lot more specific about your problem and what help you need! Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with.
 
Share this answer
 
Comments
Member 14013003 8-Jun-19 12:02pm    
Thanks its working :)
Member 14013003 8-Jun-19 12:15pm    
One more question is how can i add the icon, the icons of the shortcuts
OriginalGriff 8-Jun-19 12:29pm    
That is a heck of a lot more complicated!
First you have to read the link file:
https://docs.microsoft.com/en-gb/windows/desktop/shell/links
https://www.codeproject.com/Articles/11467/How-to-create-short-cuts-link-files
The second creates them, but it is at least C# code that can be used as a basis for reading them.

Then ... you need to show the icon together with the shortcut name in a ComboBox, and that's not simple either.
This will help, probably:
http://csharphelper.com/blog/2016/03/easily-make-owner-drawn-comboboxes-display-images-with-text-in-c/
But ... if you had difficulty displaying the files on their own, I suspect that you are trying to punch way above your weight, and really need to concentrate on the basics rather than leaping into complicated stuff and hoping for the best...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900