how to get the name of the files which is there in a specified folder

Raj_Chennai
Posted by Raj_Chennai under C# category on | Points: 40 | Views : 996
private void button1_Click(object sender, RoutedEventArgs e)
{
if (Directory.Exists("C:\\sm") == true)
{

string[] files = Directory.GetFiles("C:\\sm");
if (files.Length == 0)
{
MessageBox.Show("There is no files to collect!");

}
else
{
foreach (string f in files)
{

listBox1.Items.Add(System.IO.Path.GetFileName(f).ToString());

}
}

}
}

Comments or Responses

Login to post response