This article will show how to get list of all
files present in directory in windows
application using c#.net. In this
I have shown the directory file in the listbox.
Some
of my previous articles are as follows: Bind
DataGridView With DataTable Using C#.Net In Windows Application, Display
DataGridView Selected Row Values To Second From Using C# In Windows Application, How
To Convert Text Into Image In C# In Windows Application, Detecting
Ctrl+ V Key Pressed Or Stroke Using C# & VB.Net In Windows Application, Group
CheckBox In C# WinForm, How
To Read XML File In DataSet And Display in DataGridview Using C#.Net, WebBrowser
Control in C#, Windows Application, Change
Control Font Size At Runtime / Dynamically Using C#.Net and VB.Net In Windows
Application.
So for this article first we will create a new
windows
application and add textbox, button and list box control.
Now generate the button click event and add
the below code into the form.
private void button1_Click(object sender, EventArgs e)
{
string[] filePaths = Directory.GetFiles(txtDirectoryPath.Text);
listBox1.DataSource = filePaths;
lblcount.Text = filePaths.Length.ToString();
}
|
0 comments:
Please let me know your view