"Amos Soma" <amos_j_soma@y_a_hoo.com> wrote in message
news:0s********************@buckeye-express.com...
Thanks Ben. I know I can do that. I was hoping this wasn't the 'easiest'
way
to do it.
There is an easier way, use System.Management classes and WMI's
Win32_Directory class .
Following is a sample:
using System.Management;
.....
string dirName = @"c:\\source"; // beware the double quotes!
string objPath = "Win32_Directory.Name=" + "\"" + dirName + "\"";
using (ManagementObject dir= new ManagementObject(objPath))
{
ManagementBaseObject inputArgs = dir.GetMethodParameters("CopyEx");
inputArgs["FileName"] = "C:\\destination";
inputArgs["Recursive"] = true; // Recurse folder and subfolders
ManagementBaseObject outParams = dir.InvokeMethod("CopyEx", inputArgs,
null);
uint ret = (uint)(outParams.Properties["ReturnValue"].Value);
if(ret == 0)
Console.WriteLine("Success");
else Console.WriteLine("Failed with error code: {0}", ret);
}
Willy.