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();
}
}
}
c#读取文本并生成txt的更多相关文章
- 利用Python读取文件名并生成txt文件——以图片文件为例
效果如下: 代码: import os class ReadImageName(): def __init__(self): self.path = '.' def readname(self): f ...
- C#读取固定文本格式的txt文件
C#读取固定文本格式的txt文件 一个简单的C#读取txt文档的程序,文档中用固定的格式存放着实例数据. //判断关键字在文档中是否存在 ] == "设备ID:107157061" ...
- js读取文本内容,支持csv.txt
js读取文本内容,支持csv.txt <!DOCTYPE html> <html> <head> <meta charset="UTF-8" ...
- java读取字符串,生成txt文件
/** * 读取字符串,生成txt 文件 已解决未设置编码时,在项目中直接打开文件,中文乱码问题 * WriteText.writeToText(musicInfo,fileName)直接调用 * * ...
- 使用 T4 文本模板生成设计时代码
使用设计时 T4 文本模板,您可以在 Visual Studio 项目中生成程序代码和其他文件. 通常,您编写一些模板,以便它们根据来自模型的数据来改变所生成的代码. 模型是包含有关应用程序要求的 ...
- Python读取文本,输出指定中文(字符串)
因业务需求,需要提取文本中带有检查字样的每一行. 样本如下: 1 投入10kVB.C母分段820闭锁备自投压板 2 退出10kVB.C母分段820备投跳803压板 3 退出10kVB.C母分段820备 ...
- JSON C# Class Generator是一个从JSON文本中生成C#内的应用程序
JSON C# Class Generator是一个从JSON文本中生成C#内的应用程序 .NET平台开源项目速览(18)C#平台JSON实体类生成器JSON C# Class Generator ...
- MySQL中游标使用以及读取文本数据
原文:MySQL中游标使用以及读取文本数据 前言 之前一直没有接触数据库的学习,只是本科时候修了一本数据库基本知识的课.当时只对C++感兴趣,天真的认为其它的课都没有用,数据库也是半懂不懂,胡乱就考试 ...
- [日常] Go-逐行读取文本信息
go逐行读取文本信息:1.os包提供了操作系统函数的不依赖平台的接口,Open方法打开一个文件用于读取,func Open(name string) (file *File, err error)2. ...
随机推荐
- c++中关于预编译头的设置问题
在运行代码时会遇到缺少预编译pch.c 或者stadfx.h之类的, 这个时候,先查看有没有包含, 然后看一下预编译头设置中, 是否正确设置.
- .NET并行计算和并发3.2-多线程调用Invoke
以下这个例子是用一个后台线程执行计算逻辑,这样不影响前台界面操作,也就是说 可以在前台UI界面执行其他操作. 重点是新线程中,调用了一个委托方法,这个方法是需要填充数据到前台控件,因为 前台控件是在原 ...
- 【linux基础】cuDNN版本查询
参考 1. 查看cudnn版本; 完
- A Statistical Model for Scientific Readability-paper
Authors: Luo SiCarnegie Mellon University, Pittsburgh, PA Jamie CallanCarnegie Mellon University, Pi ...
- POJ 1284:Primitive Roots(素数原根的个数)
Primitive Roots Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 5709 Accepted: 3261 Descr ...
- hibernate模拟(转载)
package simulation; /** * * @author Administrator * */ public class User { private int id; private S ...
- Django 数据库迁移
Django 数据库迁移 DATABASES = { # Django默认配置使用sqlite3数据库 # 'default': { # 'ENGINE': 'django.db.backends.s ...
- java fail-fast和fail-safe
快速失败(fail—fast) 在用迭代器遍历一个集合对象时,如果遍历过程中对集合对象的内容进行了修改(如增加.删除等),则会抛出Concurrent Modification Exception. ...
- sso cas4.0改造历程--spring-webflow篇
https://blog.csdn.net/sinat_20689109/article/details/54910642
- Delphi2009之TImage
TPngImage原来是SourceFroge上的一个开源项目,现在突然消失了,为什么呢?Nick 在他的博客上写到:TPNGImage被CodeGear/Embarcadero收购了,现在直接就是D ...