热门:网页模板.net视频教程JQueryMVCjsonExtJs源码示例三级联动JQuery菜单
您现在的位置:.Net中文社区>> .Net编程>>正文内容

C#操作.txt文本文件

发布时间:2009年01月08日点击数: 未知
C#追加文件
StreamWriter sw = File.AppendText(Server.MapPath(".")+"\\myText.txt");  
sw.WriteLine("追逐理想");  
sw.WriteLine("kzlll");  
sw.WriteLine(".NET笔记");  
sw.Flush();  
sw.Close();

C#拷贝文件
string OrignFile,NewFile;  
OrignFile = Server.MapPath(".")+"\\myText.txt";  
NewFile = Server.MapPath(".")+"\\myTextCopy.txt";  
File.Copy(OrignFile,NewFile,true);
C#删除文件
string delFile = Server.MapPath(".")+"\\myTextCopy.txt";  
File.Delete(delFile);
C#移动文件
string OrignFile,NewFile;  
OrignFile = Server.MapPath(".")+"\\myText.txt";  
NewFile = Server.MapPath(".")+"\\myTextCopy.txt";  
File.Move(OrignFile,NewFile);

感谢你的阅读,希望能对你有所帮助!

本站热点业务

更多模板/案例展示

关于我们 | 联系我们 | 团队日志 | 网站地图 | 网站合作