Click here to Skip to main content
16,004,406 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
PopulateListBox(listBox1, @"C:\test", "*.*");

}
private void PopulateListBox(ListBox lsb, string Folder, string FileType)
{
    DirectoryInfo dinfo = new DirectoryInfo(Folder);
    FileInfo[] Files = dinfo.GetFiles(FileType);
    foreach (FileInfo file in Files)
    {
        lsb.Items.Add(file.Name);
    }
}
private void listBox1_MouseClick(object sender1, MouseEventArgs e)
{

    Process.Start(@"EXCEL.EXE", (@"C:\test") +    @"\" + (sender1 as ListBox).SelectedItem.ToString());
}
private void listBox1_SelectedIndexChanged(object sender1, EventArgs e)
{

}

private void listBox1_SelectedIndexChanged_1(object sender, EventArgs e)
{
}
Posted
Updated 21-Mar-17 22:44pm

there is a method for getting filename without extension

C#
result = Path.GetFileNameWithoutExtension(fileName);


Refer it
get filename without extension
 
Share this answer
 
Comments
agent_kruger 22-Feb-14 23:05pm    
+5
King Fisher 23-Feb-14 23:26pm    
thanks
foreach (string f in Directory.GetFiles(folderName))
                {
                    if (f.ToLower().EndsWith(".jpg")==true || f.ToLower().EndsWith(".jpeg")==true)
                    {
                        this.listBox1.Items.Add(Path.GetFileNameWithoutExtension(f));
                        this.textBox1.Text = folderBrowserDialog1.SelectedPath;
                    }
 
Share this answer
 

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