C# txt文档内容的事情
Regex rgx =
new
Regex(
@"http://www.XXXX.com/file/\d{10}/"
);
string
path =
@"H:\"
, newTxt =
@"H:\newTxt.txt"
;
var query1 = from f
in
Directory.GetFiles(path)
let arr = File.ReadAllLines(f)
where f.EndsWith(
".txt"
)
select
new
{
content = (from c
in
arr
where rgx.IsMatch(c)
select c)
};
query1.ToList().ForEach(item => File.AppendAllLines(newTxt, item.content));
foreach
(var str
in
File.ReadAllLines(newTxt))
{
Console.WriteLine(str);
}