using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ReadAndWrite
{
class Program
{
public static void WriteFile(string str, string WritePath)
{
StreamWriter sw = new StreamWriter(WritePath, true, System.Text.Encoding.Default);
sw.WriteLine(str);
sw.Close();
}
public static void RedFile(string Redpath, string WritePath)
{
StreamReader sr = new StreamReader(Redpath, Encoding.Default);
//string[] trimlines = System.IO.File.ReadAllLines(AllTrimPath);
String line;
while ((line = sr.ReadLine()) != null)
{
Console.WriteLine(line);
WriteFile(line, WritePath);
}
}
static void Main(string[] args)
{
string Readpath = "C:\\Users\\v-rusu\\Documents\\ReadAndWrite\\Read.txt";
string WritePath = "C:\\Users\\v-rusu\\Documents\\ReadAndWrite\\Write.txt";
RedFile(Readpath, WritePath);
}
}
}
C#: Read and write
最新推荐文章于 2022-06-28 20:20:51 发布