zoukankan      html  css  js  c++  java
  • 3月19日 流

    1、写入流

                  string filename = saveFileDialog1.FileName;
                        //写入流,可以在硬盘上创建文件,并为文件写入信息
                        StreamWriter sw = new StreamWriter(filename);
                        sw.Write(this.textBox1.Text);                      //this:代表的它所在的那个类当前对象
                        sw.Close(); 
    (1)、点击写入                                          (2)、找到文件,打开

    QQ截图20150319135933                 QQ截图20150319140058

    2、读入流:

         openFileDialog1.Filter="文本文档|*.txt|所有文件|*.*";             //设置读取格式
                openFileDialog1.ShowDialog();                  //打开对话框

            string filename = openFileDialog1.FileName;
                   //通过读入流进行文件读取
                   StreamReader sr = new StreamReader(filename);
                   textBox1.Text = sr.ReadToEnd();    //ReadToEnd从头读到尾           
                   sr.Close();               //关闭流

    (1).点击打开                                                   (2)、选中显示

            QQ截图20150319134718         QQ截图20150319134817

    3、FileStream:(用控件pictureBox)

    专门用于程序与硬盘之间文件读写的操作,

                  //文件流
                    FileStream fs = new FileStream(openFileDialog1.FileName,FileMode.Open,FileAccess.Read);
                    Image img = System.Drawing.Bitmap.FromStream(fs);
                    pictureBox1.Image = img;

    4、图片类:

    二进制数据的话:bianaryReader

    FileStream fs = new FileStream(openFileDialog1.FileName, FileMode.Open, FileAccess.Read);
                   BinaryReader br = new BinaryReader(fs);
                   byte[] buffer = br.ReadBytes(int.Parse(fs.Length.ToString()));
    5、MemoryStream:用于程序和内存之间进行操作数据,一般用于程序和数据库中间的中转

  • 相关阅读:
    https://www.cnblogs.com/marost/p/4668664.html
    UEFI 坑 Ubuntu
    Spring《六》管理Bean
    Spring《五》集合的注入方式
    Spring《四-一》解决自动装配的问题
    spring《四》自动装配
    Spring《三》ref 引用其他bean
    Spring《二》 Bean的生命周期
    Spring《一》
    Fragment间相互调用并传值
  • 原文地址:https://www.cnblogs.com/tzq9308/p/4350694.html
Copyright © 2011-2022 走看看