怎么才读取一个文件中的内容哪?那位老兄可以给出代码。
解决方案 »
- c# webcllient 的uploadstring() 方法服务器端如何接收?
- 文本公式解析
- 求C#socket编程高手啊。。。
- AxwebBrowser.Document强制转化IHTMLDocument2无效?!
- 调用非托管dll的问题
- 哪位大虾对Wxv.Comet这个服务器消息推送的demo有研究?告诉我如何处理中文乱码
- 怎么实现QQ空间那样登陆弹出
- How to:实现在DataGird中关联表,并将关联后的内容作为DataGird的列
- C#(WinForm) : DataGrid导出Excel ,求解决方案与源码:)
- 求一个截字符串的方法
- 关于分离字符串的问题
- picturebox的问题
StreamReader strm = f.OpenText();
string s;
s = strm.ReadLine();
while(s != null)
{
listBox1.Items.Add(s);
s = strm.ReadLine();
}
strm.Close();这样为什么有错误哪?
重载”OpenText"方法未获取“0"参数
private static void ReadFile()
{
using(FileStream fs = new FileStream("d:\\Service.Txt",FileMode.Open,FileAccess.Read))
{
StreamReader sr = new StreamReader(fs,Encoding.Default);
Console.WriteLine(sr.ReadToEnd());
sr.Close();
}
}//写文件
private static void WriteFile()
{
StringBuilder sb = new StringBuilder();
using(FileStream fs = new FileStream("c:\\CreateText.txt",FileMode.Create,FileAccess.Write))
{
StreamWriter sr = new StreamWriter(fs);
for(int i=0;i<10000;i++)
sb.Append(i.ToString("0000")+",");
sr.Write(sb.ToString(0,sb.Length-1));
sr.Close();
}
}
string s;
s = strm.ReadLine();
while (s != null)
{
listBox1.Items.Add(s);
s = strm.ReadLine();
}
strm.Close();