static void Main(string[] args)
{
Console.WriteLine("请输入地址 例如:“M://10222.txt”");
string path=Console.ReadLine();
string ss = "操作失败";
string val = "";
using (StreamReader SR = new StreamReader(path, System.Text.Encoding.Default))
{
val = SR.ReadToEnd();
SR.Close();
SR.Dispose();//释放占用的资源
}
if (null != val)
{
String[] FileRead = System.Text.RegularExpressions.Regex.Split(val, "\r\n");
val = "";
foreach (String ReadLine in FileRead)
{
if (ReadLine.Length>6)
{
val += ReadLine.Substring(0, ReadLine.Length - 6)+"\r\n";
}
else
{
val += ReadLine;
}
Console.WriteLine(val + "这是空格");
}
}
else
{
ss = "文件为空";
}
Console.WriteLine("请输入处理后的文本存放地址 如:“D:22.TXT”");
string SSQ= Console.ReadLine();
using (StreamWriter sw = new StreamWriter(SSQ))
{
sw.Write(val);
sw.Close();
sw.Dispose();
ss = "操作成功";
}
{
Console.WriteLine("请输入地址 例如:“M://10222.txt”");
string path=Console.ReadLine();
string ss = "操作失败";
string val = "";
using (StreamReader SR = new StreamReader(path, System.Text.Encoding.Default))
{
val = SR.ReadToEnd();
SR.Close();
SR.Dispose();//释放占用的资源
}
if (null != val)
{
String[] FileRead = System.Text.RegularExpressions.Regex.Split(val, "\r\n");
val = "";
foreach (String ReadLine in FileRead)
{
if (ReadLine.Length>6)
{
val += ReadLine.Substring(0, ReadLine.Length - 6)+"\r\n";
}
else
{
val += ReadLine;
}
Console.WriteLine(val + "这是空格");
}
}
else
{
ss = "文件为空";
}
Console.WriteLine("请输入处理后的文本存放地址 如:“D:22.TXT”");
string SSQ= Console.ReadLine();
using (StreamWriter sw = new StreamWriter(SSQ))
{
sw.Write(val);
sw.Close();
sw.Dispose();
ss = "操作成功";
}