【黑马程序员】File.ReadAllLines(错误)
来源:互联网 发布:android app 端口号 编辑:程序博客网 时间:2024/06/15 05:06
------- WindowsPhone 7手机开发、.Net培训、期待与您交流! -------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace test2
{
class Program
{
// 2.文本文件中存储了多个文章标题、作者,标题和作者之间用若干空格(数量不定)隔开,每行一个,标题有的长有的短,输出到控制台的时候最多标题长度10,
//如果超过10,则截取长度8的子串并且最后添加“...”,加一个竖线后输出作者的名字。
static void Main(string[] args)
{
string[] readText = File.ReadAllLines("1.txt", Encoding.Default);
foreach (string line in readText)
{
string[] str = line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
string str1;
if (str[0].Length > 10)
{
str1 = str[0].Substring(0, 8) + "...";
}
else
{
str1 = str[0] + "|";
}
string title = str[0];
string author = str[1];
Console.WriteLine("标题:{0},作者:{1}", title, author);
}
Console.ReadKey();
}
}
}
哪里出错了呢?1.txt在Debug文件下。
- 【黑马程序员】File.ReadAllLines(错误)
- 黑马程序员-File-File方法
- 黑马程序员---IO流(File类)
- 黑马程序员--(File知识总结)
- (黑马程序员)学习笔记,File对象
- 黑马程序员----IO流(File类)
- 黑马程序员--文件操作(File,RandomAccessFile)
- 黑马程序员--学习--file
- 黑马程序员:File类
- 黑马程序员-FIle-1
- 黑马程序员-FIle-2
- 黑马程序员-File类
- “黑马程序员"File
- 黑马程序员_<<File>>
- 黑马程序员---File类
- 黑马程序员--File类
- 黑马程序员:File类
- 黑马程序员_<<File>>
- “三点估算法”出题的形式演化分析
- ofbiz的webservice接口提供(4)-支持复杂数据类型方法
- ofbiz的webservice接口提供(2)-数据类型的局限性
- OJ problem 1005
- ofbiz的webservice接口提供(1)-WSDL的生成
- 【黑马程序员】File.ReadAllLines(错误)
- ofbiz和应用服务器结合
- PHP课堂--实验5
- 程序员面试宝典_程序设计基本概念
- 广度优先搜索
- hdu2717
- struts 2 的SessionAware接口使用
- 如何设置ofbiz的日志输出级别
- servlet上传附件代码