如何用用C#代码如何实现删除.CS文件中复制到的行号。刚刚入门,这种程序不怎么会编,求大神指导
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Text.RegularExpressions;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string path = ( @"F:\Game\");
System.IO.DirectoryInfo di = null;
FileInfo[] ff = null;
try
{
di = new System.IO.DirectoryInfo(path);
ff = di.GetFiles("*.cs");
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
string ss = Regex.Replace(path, @"^\s*\d+", "", RegexOptions.Multiline);
if (di.Exists)
{
foreach (FileInfo temp in ff)
{
FileStream fs = temp.OpenRead();
temp.IsReadOnly = false;
StreamReader sr = new StreamReader(fs, System.Text.Encoding.GetEncoding(936), true);
ss += sr.ReadToEnd();
}
}
else
{
Console.WriteLine("不存在该文件夹");
}
File.AppendAllText(@"F:\game\reader.txt", ss + "\r\n" );
Console.WriteLine("Thanks!");
Console.ReadKey();
}
}
}