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. ...
随机推荐
- binary and out mode to open a file
When I use binary and out mode to open a exist file, and to modify the 4th and 8th byte data to 0x78 ...
- Mondrian辅助组件----Schema WorkBench(架构平台简介)
Schema WorkBech 是Pentaho套件的另一个组件,是mondrian中schema文件生成工具.通过Schema WorkBench我们可以快速生成一个schema文件,不再需要手写. ...
- ubuntu 网络配置
检查网络配置命令:ifconfig 一.通过配置文件配置 新手没怎么用过Ubuntu,所以走了不少弯路,网上找了很多方法,大都没对我起到帮助作用,所以把自己的配置方法写一写. Ubuntu上连了两块网 ...
- Vxlan基础理解
一 . 为什么需要Vxlan 1. vlan的数量限制 4096个vlan远不能满足大规模云计算数据中心的需求 2. 物理网络基础设施的限制 基于IP子网的区域划分限制了需要二层网 ...
- python基础--字符串
字符串 1.形式 单引号括起来的字符串:'hello' 双引号括起来的字符串:"Hello" 三引号括起来的字符串:'''hello'''(三单引号),""&q ...
- Js/对数组的认识。
1.是对数组的声明: var auditTaskIds = []; 我一般的写法. var auditTaskIds1 = []; 2.向数组中添加元素: auditTaskIds.pu ...
- Post Order traverse binary tree using non-recursive way
Process analysis Stack = 5, Push 3, Stack = 5, 3. Pre = 5 Current = 3, Pre = 5, Push 2 to the st ...
- 【转载】 Deepmind星际争霸2平台使用第一轮-完成采矿
原文地址: https://blog.csdn.net/woaipichuli/article/details/78645999 ----------------------------------- ...
- brand new start
做了约两年半的安全,留下了约五十多篇笔记,从电脑搬过来,免的丢了
- 一个nginx服务器配置多站点
有时候你想在一台服务器上为不同的域名运行不同的站点.比如www.siteA.com作为博客,www.siteB.com作为论坛.你可以把两个域名的IP都解析到你的服务器上,但是没法在Nginx的根目录 ...