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);

 

posted @ 2015-09-22 11:32  尘梦  阅读(1909)  评论(0编辑  收藏  举报