C# 读取text内容并向text写入内容,对文本进行读写

语言:C#,平台VS2013,按行读取text内容,并按行写入新建的text中。
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Configuration;
using System.Text;
using System.IO;

namespace testtwo
{
    struct Time
    {
        private int hours, minutes, seconds;
        //private int a = 0;

        public Time(int hh, int mm, int ss)
        {
            hours = hh;
            minutes = mm;
            seconds = ss;
        }

        public Time(int hh, int mm)
        {
            hours = hh;
            minutes = mm;
            seconds = 0;
        }

        public int Hours()
        {
            return hours;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            
            /*
            Time t = new Time();
            Console.WriteLine(t.Hours());

            Time t2 = new Time(10, 20, 30);
            Console.WriteLine(t2.Hours());

            Time t3 = new Time(10, 20);
            Console.WriteLine(t3.Hours());
            Console.ReadKey();
            */
            string[] pointname = new string[10];
            int k = 0;
            //----------------------------------------------------------read pointname-----------------------------------------------------------------------------------    
            FileStream aFile = new FileStream("f:\\pointname.txt", FileMode.Open);
            StreamReader sr = new StreamReader(aFile);
            string strLine = sr.ReadLine();
            pointname[0] = strLine;
            while (strLine != null)
            {
                k++;
                strLine = sr.ReadLine();
                pointname[k] = strLine;
                
            }
            sr.Close();
            foreach (var temp in pointname) 
            {
                Console.WriteLine(temp);
                
            }
            StreamWriter sw = new StreamWriter("f:\\histime_data.txt", true, Encoding.GetEncoding("gb2312"));
            for (int i = 0; i 

贴上代码,注释的内容不用看。

你可能感兴趣的:(C#,VS)