c#读取文本并生成txt

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO; namespace WindowsFormsApp2
{
public partial class Form1 : Form
{ List<string> listTxt = new List<string>();
public Form1()
{
InitializeComponent();
} private void button1_Click(object sender, EventArgs e)
{
Read();
Write();
} byte[] byData = new byte[];
char[] charData = new char[];
public void Read()
{
StreamReader sr = new StreamReader(System.Environment.CurrentDirectory+"/"+"22.txt", Encoding.Default);
String line;
while ((line = sr.ReadLine()) != null)
{
string txt = line;
txt = txt.Replace(@"\N{\fs14}", ";");
string[] txtnew = txt.Split(';');
if (txtnew.Length > )
{
listTxt.Add(txtnew[]);
listTxt.Add(txtnew[]);
}
//Console.WriteLine(line.ToString());
}
} public void Write()
{
FileStream fs = new FileStream(System.Environment.CurrentDirectory+"/第1季第22集.txt", FileMode.Create);
StreamWriter sw = new StreamWriter(fs);
//开始写入
foreach (var item in listTxt)
{
sw.WriteLine(item);
}
//清空缓冲区
sw.Flush();
//关闭流
sw.Close();
fs.Close();
}
}
}
上一篇:js DOM Node类型


下一篇:gcc/g++基本命令简介