using System;
using System.IO;
class Test
{
    public static void Main()
    {
        //ҪĿ¼ַ
        string path = @"c:\MyDir";
        //ҪƵĿĿ¼ַ
        string target = @"c:\TestDir";
        try
        {
            // жpathָĿ¼Ƿ
            if (!Directory.Exists(path))
            {
                // pathָĿ¼ʹ
                Directory.CreateDirectory(path);
            }
            if (Directory.Exists(target))
            {
                // targetָĿ¼ɾ
                Directory.Delete(target, true);
            }
            // pathָĿ¼ƶtargetָĿ¼
            Directory.Move(path, target);
            // ָĿ¼ļmyfile.txt
            File.CreateText(target + @"\myfile.txt");
            // targetָĿ¼еļCount the files in the target directory.
            Console.WriteLine("{0}Ŀ¼еļǣ{1}",
target, Directory.GetFiles(target).Length);
        }
        catch (Exception e)
        {
            Console.WriteLine("ԭǣ {0}", e.ToString());
        }
        finally { }
        Console.ReadLine();
    }
}
