读取二进制文件的语句怎么写???

wpf123 2006-09-13 09:58:15
以二进制流的方式读取文件的语句怎么写???谢谢了
...全文
135 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
Knight94 2006-09-13
  • 打赏
  • 举报
回复
通过FileStream来读取文件,msdn有例子。
yuxing117 2006-09-13
  • 打赏
  • 举报
回复
System.IO.StreamReader sr=new StreamReader(文件路径,编码方式);
wpf123 2006-09-13
  • 打赏
  • 举报
回复
以二进制流的方式读取文件的语句怎么写???谢谢了
comingkmboy 2006-09-13
  • 打赏
  • 举报
回复
//读文本文件
this.openFileDialog1.ShowDialog();
string MyFileName=this.openFileDialog1.FileName;
if(MyFileName.Trim()=="")
return;
StreamReader MyReader=null;
try
{
MyReader=new StreamReader(MyFileName,System.Text.Encoding.Default);
this.richTextBox1.Text=MyReader.ReadToEnd();
}
catch(Exception Err)
{
MessageBox.Show("读文本文件发生错误!请检查源文件是否是文本文件?","信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
return;
}
finally
{
if(MyReader!=null)
{
MyReader.Close();
}
}
LMTZ 2006-09-13
  • 打赏
  • 举报
回复
FileStream fs = System.IO.File.Open(path, System.IO.FileMode.Open);

110,533

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧