Thursday, August 12, 2010

How to copy all files in one folder to another folder.

protected override void OnLoad(EventArgs e)
{
    base.OnLoad(e);
 
    string on = @"C:\PathOldFolder";
    string nn = @"C:\PathNewFolder";
    Directory.CreateDirectory(nn);
    this.Copy(new DirectoryInfo(on), new DirectoryInfo(nn));
}
 
public void Copy(DirectoryInfo o, DirectoryInfo n)
{
    foreach (FileInfo f in o.GetFiles())
    {
        string nfn = f.FullName.Replace(o.FullName, n.FullName);
        File.Copy(f.FullName, nfn);
    }
    foreach (DirectoryInfo c in o.GetDirectories())
    {
        string ndn = c.FullName.Replace(o.FullName, n.FullName);
        Directory.CreateDirectory(ndn);
        this.Copy(c, new DirectoryInfo(ndn));
    }
}

No comments:

Azure Storage Account Types

Defferent Types of Blobs Block blobs store text and binary data. Block blobs are made up of blocks of data that can be managed individually...