數據格式化

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace convert
{
    class Program
    {
        static void Main(string[] args)
        {


            StreamWriter swWriteFile = File.CreateText("D:\\data\\data\\prsz.txt");
            string strReadFilePath = @"D:\\data\\data\\rsz.txt";
            StreamReader srReadFile = new StreamReader(strReadFilePath);
            // 讀取流直至文件末尾結束
            while (!srReadFile.EndOfStream)
            {
                string strReadLine = srReadFile.ReadLine(); //讀取每行數據

                swWriteFile.WriteLine(strReadLine.Substring(strReadLine.Length - 7, 6)); //屏幕打印每行數據
            }
           





           /*

            StreamWriter swWriteFile = File.CreateText("D:\\data\\data\\rsz.txt");
            string txt = "";
            StreamReader sr = new StreamReader("D:\\data\\data\\sz.txt", Encoding.GetEncoding("GB2312"));
            txt = sr.ReadToEnd();
            string[] arr = txt.Split(' ');
            for (int i=0;i<arr.Length;i++)
            { 
                swWriteFile.WriteLine(arr[i]);//寫入讀取的每行數據
            }
            swWriteFile.Close();
              */
       }
    }
}






 
相關文章
相關標籤/搜索