How to get files using C Sharp |
|
Hi,
How to get file names from the directory using C#?
|
RajKumar |
Answered# (13)
|
Reply For This Question
|
|
|
Answer(s) Posted
|
|
How to get files using C Sharp
|
|
namespace
using System.IO;
Code to get filename with full directory path:
string[] files = Directory.GetFiles(path, filter);
After getting list of files. Iterate through the collection to get only file name
for (int i = 0; i < files.Length; i++)
{
var fileName = Path.GetFileName(files[i]);
Console.WriteLine(fileName);
}
|
Raj Kumar
| Answered# (13)
|
|
|
Post Your Answer
|
Please login to post your answer.
|
|
|