All articles(网络文学目录) All Pictures(图片目录) All Softwares(软件目录)

 
C#对文件的操作_[Asp.Net教程]

Writer: delv Article type: Programming skills(编程技巧) Time: 2014/1/10 6:29:16 Browse times: 361 Comment times: 0

C#对文件的操作_[Asp.Net教程]


Head photo

Go homepage
Upload pictures
Write articles

C#对文件的操作_[Asp.Net教程]

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");
}

来源:网络





There are 0 records,
Comment:
Must be registered users to comment(必须是注册用户才能发表评论)

Disclaimer Privacy Policy About us Site Map
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.