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


     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
  • 相关阅读:
    leetcode 203
    vim插件管理器vundle
    centos7看电影
    getopt
    iOS/object-c: 枚举类型 enum,NS_ENUM,NS_OPTIONS
    "ALView+PureLayout.h"
    UIPageViewController教程
    (Mac ox 10.11+) CocoaPods安装,卸载,使用说明
    CocoaPods集成到Xcode项目中的步骤
    label_设置行距、字距及计算含有行间距的label高度
  • 原文地址:https://www.cnblogs.com/CandiceW/p/4204565.html
Copyright © 2020-2023  润新知