代碼很簡單,就不做解釋了,直接拷貝可用。
更多示例代碼,可以訪問微軟示例代碼(Samples from microsoft)All-In-One Code:<A href=
"http://1code.codeplex.com"
>http://1code.codeplex.com</A>
<PRE
class
=brush:csharp;gutter:
false
;><DIV
class
=cnblogs_Highlighter><PRE
class
=brush:csharp;gutter:
false
;>
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
System.IO;
namespace
ZipOneCode.FileProvider
{
public
class
FileHelper
{
/// <summary>
/// 復制文件夾(及文件夾下所有子文件夾和文件)
/// </summary>
/// <param name="sourcePath">待復制的文件夾路徑</param>
/// <param name="destinationPath">目標路徑</param>
public
static
void
CopyDirectory(String sourcePath, String destinationPath)
{
DirectoryInfo info =
new
DirectoryInfo(sourcePath);
Directory.CreateDirectory(destinationPath);
foreach
(FileSystemInfo fsi
in
info.GetFileSystemInfos())
{
String destName = Path.Combine(destinationPath, fsi.Name);
if
(fsi
is
System.IO.FileInfo) &n