CSharp拷贝目录文件夹到指定的目录文件夹
2011-1-24 16:48:24 - tanlixiao
CSharp拷贝目录文件夹到指定的目录文件夹,.net提供了System.IO.DirectoryInfo和System.IO.FileInfo这两个类可实现.
CSharp拷贝目录文件夹到指定的目录文件夹,.net提供了System.IO.DirectoryInfo和System.IO.FileInfo这两个类可实现,实现代码如下:
public static bool CopyIniFileToObject(string inifilePath, string objectPath)
{
bool result = false;
try
{
System.IO.DirectoryInfo inifileDirect = new DirectoryInfo(inifilePath);
System.IO.FileInfo[] files = inifileDirect.GetFiles();
string sourcePath = inifileDirect.FullName;
foreach (System.IO.FileInfo item in files)
{
string sourceFileFullName = item.FullName;
string destFileFullName = sourceFileFullName.Replace(sourcePath, objectPath);
item.CopyTo(destFileFullName, true);
}
result = true;
}
catch
{
result = false;
}
return result;
}