ReadAllFiles(@"../../","names.txt"); I tried this so I am able to read the file.But what I want is to read a file without giving filename and it should read only file with some particular extension like .csv, .xml only
Asked
Active
Viewed 437 times
1 Answers
1
You can read like this. you have to give folder path and the pattern of you want to read the file.You can use GetFiles method also.
string path = "";
foreach (string file in Directory.EnumerateFiles(path, "*.txt"))
{
string content = File.ReadAllText(file);
}
vivek nuna
- 16,885
- 12
- 74
- 152