Q:

How to list files in directory C# WPF

I need to get file list without directory name and without file extenstion
in 
C:\ProgramData\Microsoft\Windows\Start Menu\Programs
ex)C:\ProgramData\Microsoft\Windows\Start Menu\Programs\7-Zip\7-Zip File Manager.lnk (X)
7-Zip File Manager                                                                (O)
and list those files in Listbox.
I also have to retrive icon and start program if the file name is selected in listbox.
Like this.
http://www.c-sharpcorner.com/UploadFile/7e39ca/display-start-menu-in-windows-8/Images/Start-Menu-Windows8.jpg
can anybody help me?
Thanks.

A:

Use Path.GetFileNameWithoutExtension for retrieving the file name
string fileName = Path.GetFileNameWithoutExtension("C:\ProgramData\Microsoft\Windows\Start Menu\Programs\7-Zip\7-Zip File Manager.lnk);

For listing icons in a listbox, look into WPF ListView Class. You need to define a template in XAML for displaying images:
<ListView>
    <ListView.Resources>
        <DataTemplate x:Key="IconTemplate">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>
                <Image Grid.Column="0"/>
                <TextBlock Grid.Column="1" Text="{Binding Name}"/>
            </Grid>
        </DataTemplate>
    </ListView.Resources>            
    <ListView.View>     
        <GridView>
            <GridViewColumn CellTemplate="{StaticResource IconTemplate}" Header="Name"/>
            <GridViewColumn DisplayMemberBinding="{Binding FileName}" Header="File Name"/>                   
        </GridView>
    </ListView.View>
</ListView>

To extract the icon from file, you can use ExtractAssociatedIcon from System.Drawing namespace:
Icon icon = Icon.ExtractAssociatedIcon(filePath);

