0

I just need a head start on how can I list the files inside a folder to a form. What I am planning is to put shortcut files inside a folder, make the form list all files and launch the files through the form.

marneee
  • 25
  • 1
  • 3
  • 1
    Could you specify your problem more specific? What are you exactly stuck with and try to google first as there are a lot of questions which answer this already. [List Files in folder](https://stackoverflow.com/questions/11861151/find-all-files-in-a-folder), [Launch applications](https://stackoverflow.com/questions/240171/launching-an-application-exe-from-c) – Twenty Oct 26 '19 at 14:44
  • 1
    Please post your work ..if you done anything yet don't just come here ask for work done . people are here to help not to do your work. just post your code and then people will correct you . – Er. Amit Joshi Oct 26 '19 at 14:45

1 Answers1

0

I don't have enough rep to comment to the OP so I have to answer unfortunately.

    string[] array2 = Directory.GetFiles(@"C:\MyFolderOfShortcuts", "*.LNK");

This gets all shortcut files in a directory and saves it to an array. You can populate something like a listbox with the results and then add an onclick to the listbox to open the shortcut.

Please update us when you have some code written and we'll help you further.

Edit Since I had to post as an answer let me be a bit more thorough:

    public Form1()
    {
        InitializeComponent();
        string ShortcutDirectory = @"C:\Users\user\Desktop\";
        string[] Shortcuts = Directory.GetFiles(ShortcutDirectory, "*.lnk");
        foreach (string name in Shortcuts)
        {
            listBox1.Items.Add(name);
        }       
    }
Mikael
  • 1,002
  • 1
  • 11
  • 22