【发布时间】:2012-11-20 16:56:48
【问题描述】:
您好,我目前正在完成编程课的最后一项作业,而且我对编程领域还很陌生。我的任务是通过 Streamreader 流式传输文档并提取信息以供菜单程序访问文档。
到目前为止,我只能流式传输
using System;
using System.IO;
class Test
{
public static void Main()
{
try
{
Directory.SetCurrentDirectory(@"\Users\changl\Desktop");
using (StreamReader sr = new StreamReader("earthquakes.csv"))
{
String line;
while ((line = sr.ReadLine()) != null)
{
Console.WriteLine(line);
}
}
}
catch (Exception e)
{
Console.WriteLine("The file could not be read:");
Console.WriteLine(e.Message);
}
}
}
我在编程方面颇有经验,希望得到一些帮助,了解下一步如何将信息保存在文档中以供以后使用。
【问题讨论】: