• 打开文件并读取文件内容


     public partial class MainWindow : Window
        {
            private OpenFileDialog openFileDialog = null;
           
            public MainWindow()
            {
               InitializeComponent();
               openFileDialog = new OpenFileDialog();
               openFileDialog.FileOk += openFileDialogFileOk;


            }


            private void openBtn_Click(object sender, RoutedEventArgs e)
            {
                openFileDialog.ShowDialog();
            }


          


            private void openFileDialogFileOk(object sender, System.ComponentModel.CancelEventArgs e)
            {
                string fullPathName = openFileDialog.FileName;
                FileInfo str = new FileInfo(fullPathName);
                fileNameText.Text = str.Name;
                contentText.Text = "";
                TextReader reader = str.OpenText();
                string line = reader.ReadLine();
                while (line != null)
                {
                    line = reader.ReadLine();
                    contentText.Text +=line +' ';
                   
                }
                reader.Close();




            }
        }
    If opportunity doesn’t knock, build a door
  • 相关阅读:
    查看串口设备
    JavaScript 闭包
    JS中decodeURI()与decodeURIComponent()
    js 获取浏览器高度和宽度值(多浏览器)
    几种常用网页返回顶部代码
    CSS3 Transition
    jquery操作css
    如何改变hr的颜色
    标签导航——display属性
    思考性能问题
  • 原文地址:https://www.cnblogs.com/CandiceW/p/4204565.html
Copyright © 2020-2023  润新知