SETHA SITE INFORMATION

  • Increase font size
  • Default font size
  • Decrease font size

How to get file name from a specified directory in C#.Net?

E-mail Print PDF
The below VB.Net code uses to get all document files (*.docx) in directory C:\Test\. For example, if we have 3 document files (.docx) in C:\Test\ directory then the below code will result those three files in full path on 3 message boxes sequentially. C# Code
string[] strFiles;
strFiles = System.IO.Directory.GetFiles("C:\\Test\\","*.docx");
foreach (string str in strFiles)
{
    MessageBox.Show(str);
}