C# code
c# code to get files from one folder to another folder on button click?
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
VulpesRank #55 · 29.2K reputationPosted Feb 25, 2013, 6:14 AM EST
private button1_Click(object sender, EventArgs e)
{
string sourceFolder = @"c:\whatever";
string destinationFolder = @"c:\whatever2";
foreach(string sourcePath in Directory.GetFiles(sourceFolder))
{
string destinationPath = destinationFolder + "\\" + Path.GetFileName(sourcePath);
if(!File.Exists(destinationPath)) File.Move(sourcePath, destinationPath);
}
}
Manjunatha Srinivasappa9 reputationPosted Feb 25, 2013, 7:54 PM EST