1

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

1

1 Answer 1

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); } 
Sign up to request clarification or add additional context in comments.

Comments