how to copy a folder to another folder on button clk in asp.net

Jayakumars
Posted by Jayakumars under ASP.NET AJAX category on | Points: 40 | Views : 1410
hi

I have post the code for how to copy a folder to another folder on button clk in asp.net


protected void bt1_Click(object sender, EventArgs e)
{
string sourcePath = @"C:\Jesus";
string targetPath = @"D:\Jesus";

if (System.IO.Directory.Exists(sourcePath))
{
string[] files = System.IO.Directory.GetFiles(sourcePath);
foreach (string s in files)
{
string fileName = System.IO.Path.GetFileName(s);
string destFile = System.IO.Path.Combine(targetPath, fileName);
System.IO.Directory.CreateDirectory(@"D:\Jesus");
System.IO.File.Copy(s, destFile, true);
}
Response.Write("Sucessfully Created");
}

}

Comments or Responses

Login to post response