紧急求救Rename() 急需解决文件重命名问题解决问题给分QQ:280600958 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 没有Rename方法.File.Move(a,b)就可以把a重命名为b string srcFileName=@"c:\meng\a.txt";string destFileName=@"c:\meng\b.txt";string srcFolderPath=@"c:\temp";string destFolderPath=@"c:\temp11";//方法一 if (System.IO.File.Exists(srcFileName)) { System.IO.File.Move(srcFileName,destFileName);} if (System.IO.Directory.Exists(srcFolderPath)) { System.IO.Directory.Move(srcFolderPath,destFolderPath);}//方法二if (System.IO.File.Exists(srcFileName)) { System.IO.FileInfo file=new System.IO.FileInfo(srcFileName); file.MoveTo(destFileName); } if (System.IO.Directory.Exists(srcFolderPath)) { System.IO.DirectoryInfo folder=new System.IO.DirectoryInfo(srcFolderPath); folder.MoveTo(destFolderPath); } 逻辑算法求思路…… 正则表达式应用--提取CSDN所有下载资源URl的思路与代码实现分享 dataset找重复字段 VS2005做安装程序时一加图标就报错? 求一个的DotNet代码 用过installer类的帮帮忙,多谢! C#的匿名构造函数怎么写? Repeater 嵌套 关于RichText控件的问题 在win form程序中如何获取本机的IP地址?(不是web form) 简单的线程问题 web问题
就可以把a重命名为b
string destFileName=@"c:\meng\b.txt";string srcFolderPath=@"c:\temp";
string destFolderPath=@"c:\temp11";
//方法一
if (System.IO.File.Exists(srcFileName))
{
System.IO.File.Move(srcFileName,destFileName);
}
if (System.IO.Directory.Exists(srcFolderPath))
{
System.IO.Directory.Move(srcFolderPath,destFolderPath);
}//方法二
if (System.IO.File.Exists(srcFileName))
{
System.IO.FileInfo file=new System.IO.FileInfo(srcFileName);
file.MoveTo(destFileName);
}
if (System.IO.Directory.Exists(srcFolderPath))
{
System.IO.DirectoryInfo folder=new System.IO.DirectoryInfo(srcFolderPath);
folder.MoveTo(destFolderPath);
}