Get all files name from specifice folder

Get all file names in Specific Folder using C#

            Reading all file in a folder we need a path of folder, if we have a full path of folder then we pass that path in DirectoryInfo(“folderPth”) Class. This class is available in System.IO namespace

Let we see a Example of it

System.IO.DirectoryInfo dir = new System.IO. DirectoryInfo(“FolderPath”);

System.IO.FileInfo[] FileList = dir.GetFiles();

 

 

Here we call a methord getFiles() this file is return Array of FileList(All type of Files are store in FilList array)

[Note : if you want to store specific files in array then you rewrite your code like that]

System.IO.DirectoryInfo dir = new System.IO. DirectoryInfo(“FolderPath”);

System.IO.FileInfo[] FileList = dir.GetFiles(“*.doc”);

Ebook Download
View all
Learn
View all