StreamReader reader = new StreamReader("E:\\AA.txt", Encoding.GetEncoding("gb2312")); string str = reader.ReadLine(); while (!string.IsNullOrEmpty(str)) { line++; str = reader.ReadLine(); } reader.Close(); File.WriteAllTest,AppendText split分割 角色模板等实现权限管理 public static void Backup(string srcPath,string aimPath) { if (!File.Exists(srcPath)) { throw new Exception("源数据库不存在,无法备份"); } try { File.Copy(srcPath,aimPath,true); } catch(IOException ixp) { throw new Exception(ixp.ToString()); }
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO;namespace help { public partial class Form1 : Form { private StreamReader streamR; private StreamWriter streamW; public Form1() { InitializeComponent(); streamR = new StreamReader(@"d:\a.txt"); streamW = File.AppendText(@"d:\b.txt"); while (true) { string b = streamR.ReadLine(); if (b==null) {
StreamReader sr = new StreamReader(pathstr);string content = sr.ReadToEnd();
sr.Close();写
StreamWriter sw = File.AppendText(@"E:\output.txt");
//StreamWriter sw = new StreamWriter(@"E:\output.txt");sw.WriteLine(“xxxx”);sw.Close();
如:
csdn1
csdn2
……
csdn*
=================之后
woai csdn1
woai csdn2
woai ……
woai csdn*
csdn1 | csdn2|……|csdn*=================之后woai csdn1
woai csdn2
woai ……
woai csdn*
string str = reader.ReadLine();
while (!string.IsNullOrEmpty(str))
{
line++;
str = reader.ReadLine();
}
reader.Close();
File.WriteAllTest,AppendText
split分割
角色模板等实现权限管理
public static void Backup(string srcPath,string aimPath)
{
if (!File.Exists(srcPath))
{
throw new Exception("源数据库不存在,无法备份");
}
try
{
File.Copy(srcPath,aimPath,true);
}
catch(IOException ixp)
{
throw new Exception(ixp.ToString());
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;namespace help
{
public partial class Form1 : Form
{
private StreamReader streamR;
private StreamWriter streamW; public Form1()
{
InitializeComponent();
streamR = new StreamReader(@"d:\a.txt");
streamW = File.AppendText(@"d:\b.txt");
while (true)
{
string b = streamR.ReadLine();
if (b==null)
{
streamW.Flush();
streamW.Close();
break;
}
streamW.Write("csdn "); streamW.WriteLine(b);
}
} }
}测试通过,修改后的文件为b.txt,如果你认为文件名需相同,执行完后修改名称覆盖就可以了
以前我用的这个备份数据库,不过看到网上有把数据库弄成bak后缀备份的。