c#导入文件
string[] lines = System.IO.File.ReadAllLines(@"C:\Users\Administrator\Desktop\2.txt",Encoding.Default); foreach (string i in lines) { string[] ceshi = i.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); //去除空格 string title = ceshi[0]; //标题 string autor = ceshi[1];//作者 string ce = title.Substring(0); if (title.Length >= 20) { ce = title.Substring(0, 17); ce = ce + "...."; } Console.WriteLine("{0}|{1}", ce, autor);