Click here to Skip to main content
15,889,403 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello i have C# project and when i try to add code
private void button5_Click(object sender, EventArgs e)
      {
          {
              string[] files = System.IO.Directory.GetFiles(Path.Combine(@"C:\POS\Book\Book\" + label6.Text, "Prijave"));
              {

                  this.comboBox2.Items.AddRange(files);
              }


i am just getting paths.
with out of
Path.Combine
i am getting nothing

What I have tried:

I tried
string[] filePaths = Directory.GetFiles(@"C:\POS\Book\Book\" + label6.Text, "Prijave");
foreach (string file in filePaths)
{
    combobox2.items.add(file);
}

still same issue i get nothing my combobox is empty
Posted
Updated 20-Jun-17 17:28pm

1 solution

try
string[] fileNames = System.IO.Directory.GetFiles(Path.Combine(@"D:\DataLoad\" + label6.Text, "Prijave")).Select(k => Path.GetFileName(k)).ToArray();

refer Path.GetFileName Method (String) (System.IO)[^]
 
Share this answer
 
Comments
Member 13084733 20-Jun-17 23:37pm    
TNX for quick answer this works
Karthik_Mahalingam 20-Jun-17 23:38pm    
welcome

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