zoukankan      html  css  js  c++  java
  • C#—打开文件

    一、打开图片

    ps:必须先在pictureBox中导入一张图片

    private void button4_Click(object sender, EventArgs e)//选择、更换图片
    {
         if (openFileDialog1.ShowDialog() == DialogResult.OK)//需要工具箱的openFileDialog
         {
             Text = openFileDialog1.FileName;//选择图片
           Bitmap map = (Bitmap)Image.FromFile(openFileDialog1.FileName);
              pictureBox1.Image = map;//更换图片
                 
         }       
    }

    二、打开txt文档

            private void button5_Click(object sender, EventArgs e)//打开txt文档,仅限英文
            {
                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    StreamReader sr = new StreamReader(openFileDialog1.FileName);
                    string line;
                    while ((line = sr.ReadLine()) != null)
                    {
                        listBox3.Items.Add(line);
                    }
                }
            }

     

  • 相关阅读:
    2020/12/2
    2020/12/1
    Cannot do a soft reset in the middle of a merge
    webpack img
    rm -fr ".git/rebase-apply"
    css 颜色
    初始化样式
    a标签
    esma 最新
    前端
  • 原文地址:https://www.cnblogs.com/shelly0307/p/3678025.html
Copyright © 2011-2022 走看看