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:

iPhone Launch Screen Sizes

iPhone Portrait iOS 8 Retina HT 5.5 = 1242 X 2208 Retna HD 4.7 = 750 X 1134 iPhone Landscape iOS 8 Retina HD 5.5  2208 X 1242 iPho...