zoukankan      html  css  js  c++  java
  • c#的文件流的小范例

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.IO;

    namespace wht
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }

            private void button1_Click(object sender, EventArgs e)
            {
                string path = @"c:\temp\MyTest.txt";
               
                    if (File.Exists(path))
                    {
                        File.Delete(path);
                    }

                    using (StreamWriter sw = new StreamWriter(path))
                    {
                        sw.WriteLine("This");
                        sw.WriteLine("is some textvbbnvnvncfdh");
                        sw.WriteLine("to test");
                        sw.WriteLine("Reading");
                    }

                    using (StreamReader sr = new StreamReader(path))
                    {
                        string tt = "";
                        while (sr.Peek() >= 0)
                        {
                           // Console.WriteLine(sr.ReadLine());
                           tt += sr.ReadLine() + "\n";
                        }
                        MessageBox.Show(tt);
                    }
                  
            }

            private void listView1_SelectedIndexChanged(object sender, EventArgs e)
            {

            }

            private void Form1_Load(object sender, EventArgs e)
            {

            }

        }
    }

  • 相关阅读:
    IDEA远程仓库版本回滚
    智能风控平台核心之风控决策引擎(三)
    智能风控平台核心之风控决策引擎(一)
    深入理解Oracle的imp/exp 和各版本之间的规则
    oracle忘记用户密码
    Windows下使用cmd启动Oracle EM和sql命令使用+主机身份认证
    jsp调用javabean出现错误HTTP Status 500
    jsp查询页面和结果页面在同一页面显示和交互
    javabean+servlet+jsp程序_个人辛苦探索
    用Eclipse 开发Dynamic Web Project应用程序 【转】
  • 原文地址:https://www.cnblogs.com/softimagewht/p/2235247.html
Copyright © 2011-2022 走看看