日期:2014-05-17 浏览次数:21125 次
private void button5_Click(object sender, EventArgs e)
{
openFileDialog1.ShowDialog(this);
openFileDialog1.Filter = "LUA文件|*.lua|所有文件|*.*";//设置文件类型;
openFileDialog1.AutoUpgradeEnabled = true;//是否随系统升级而升级外观;
if ( openFileDialog1.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
{
textBox1.Text = openFileDialog1.FileName;
Stream read_stream = File.OpenRead(openFileDialog1.FileName);
if (File.Exists(openFileDialog1.FileName))//看看文件是否存在;
{
/*
FileStream fs = File.OpenRead(openFileDialog1.FileName);//存在的话旧打开文件;
byte[] str = new byte[20000];//定义数组来读取数据;
while (fs.Read(str, 0, str.Length) > 0)//开始从文本中读取数据;
{
Console.WriteLine(System.Text.Encoding.Default.GetString(str));//将读取的数据写出来 到屏幕上;
textBox1.Text = System.Text.Encoding.Default.GetString(str);
}
fs.Close();//关闭文件;