Copy .exe Files to new folder

  • Thread starter Thread starter Pugita
  • Start date Start date
P

Pugita

Guest
Hello.

i want copy the .exe files in folder to another folder not all of them after I click a button.

i can copy all of the files with this code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;

namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
string FROM_DIR = "C:/Users/Hamiroel Nazrin/Desktop/Home/A/B/";
string TO_DIR = "C:/Users/Hamiroel Nazrin/Desktop/Destination/";

public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
DirectoryInfo diCopyForm = new DirectoryInfo(FROM_DIR);
FileInfo[] fiDiskfiles = diCopyForm.GetFiles();
foreach (FileInfo curFile in fiDiskfiles)
{
try
{
string[] files = Directory.GetFiles(file path, "*.gift");
File.Copy(curFile.FullName, TO_DIR + curFile.Name);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

}
}
}

Continue reading...
 
Back
Top