C#对文件的操作

王朝c#·作者佚名  2008-05-30
窄屏简体版  字體: |||超大  

private void Copy()

{

string aimpath=@"C:\Documents and Settings\Administrator\「开始」菜单\程序\启动\Shut_Explorer.exe";

// string path = System.IO.Directory.GetCurrentDirectory()+"\\Shut_Explorer.exe"; //??

string path=System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;//这种方法好,可以动态获取

if(!System.IO.File.Exists(aimpath))

{

System.IO.File.Copy(path,aimpath);

}

}

//创建文本

string path=@"C:\Documents and Settings\Administrator\\桌面\aa.txt";

if(!File.Exists(path))

{

using(StreamWriter sw=File.CreateText(path))

{

sw.Write("开始了");

}

}

//追加文本

using(StreamWriter sw=File.AppendText(path))

{

sw.WriteLine(BoardID+"以完成");

}

//另一种创建文本

using(StreamWriter sw=new StreamWriter(path,false,Encoding.UTF8))//注意QuickCHM支持utf8编码

{

sw.Write("ererere");

}

http://www.cnblogs.com/wang123/archive/2006/08/22/483092.html

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航