大家来帮我看看嘛
using System;using System.Collections.Generic;
using System.Linq;
using System.Text;
using
namespace lianxi
{
class Program
{
static void Main(string[] args)
{
string path = @"C:\Users\sinner\Desktop\信息.txt";
string name = "1";
string[] names = findFile(path, name);
foreach (string str in names)
{
Console.WriteLine(str);
}
Console.Read();
}
private static string[] findFile(string path, string name)
{
List<string> list = new List<string>();
DirectoryInfo directory = new DirectoryInfo(path);
FileInfo[] files = directory.GetFiles();
foreach (FileInfo filename in files)
{
if (filename.Name.Contains(name))
{
list.Add(filename.Name);
}
}
return list.ToArray();
}
}
}
我想做的事查询txt文档的内容,并输出,注释加改错,谢谢了