C#中的读写文件
来源:互联网 发布:视频网站cms 编辑:程序博客网 时间:2024/05/19 14:53
//C#写入/读出文本文件
string fileName =@"c:/text.txt";
StreamReader sr = new StreamReader(fileName);
string str = sr.ReadLine();
sr.close();
StreamWriter rw= File.CreateText(@"c:/text.txt");
rw.WriteLine("abc");
rw.Flush();
rw.Close();
//打开文本文件
StreamReader sr = File.OpenText(@"c:/text.txt");
StringBuilder outpu = new StringBuilder();
string rl;
while((rl=sr.ReadLine())!=null)
{
output.Append(rl+"");
}
sr.Close();
//C#追加文件
StreamWriter sw = File.AppendText(@"c:/text.txt");
sw.WriteLine("yemy");
sw.Flush();
sw.Close();
//C#拷贝文件
string OrignFile,NewFile;
OrignFile = @"c:/text.txt";
NewFile = @"d:/text.txt";
File.Copy(OrignFile,NewFile,true);
//C#删除文件
string delFile = @"c:/text.txt";
File.Delete(delFile);
//C#移动文件
string OrignFile,NewFile;
OrignFile = @"c:/text.txt";
NewFile = @"d:/text.txt";
File.Move(OrignFile,NewFile);
- C#中的读写文件
- C#中的文件读写
- c#中的文件读写操作
- C#中的读写文件操作函数总结
- C#中的文件操作及文件的读写
- C#中实现读写INI文件中的值
- c#中的word 读写
- C#中的串口读写
- C#读写INI文件
- C#读写INI文件
- C#读写INI文件
- C#读写INI文件
- c#读写xml文件
- c#读写xml文件
- c#读写xml文件
- C#读写文件
- C# 文件读写
- C#读写xml文件
- sqlserver2000中的,nchar、nvarchar、char、varchar、text、ntext、image
- 张国荣5周年祭辰 张学友梁朝伟等红馆唱悼哥哥
- 用proxool配置数据库连接池步骤(properties配置)
- SQL Server 2005 创建分区应用
- C++笔记(一)
- C#中的读写文件
- SQL Server 2005 下载地址共享
- 来自黑社会兄弟的一封情书
- ASP.NET的使用
- 从ZOJ 1666看找零问题的算法
- url中文
- 为了那一万种可能
- POJ 1042
- FreeBSD下如何删除和重装软件