C#使用组合框将文件夹从C驱动器复制到可移动驱动器

时间:2018-08-11 11:04:45

标签: c# combobox copy

我尝试使用组合框将文件夹从C:\ folderX \ folderY驱动器复制到可移动驱动器:\ folderName \ 组合框选择要将文件复制到的目标驱动器。 到目前为止,我的代码

using System.IO;
namespace OptimaBackup
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            getdrive();
        }
        private void getdrive()

        {
            string[] driv = Directory.GetLogicalDrives();
            foreach (string item in driv)
            {
                comboBox1.Items.Add(item.ToString());
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {

        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            string getinfo = comboBox1.SelectedItem.ToString();
            DriveInfo drinfo = new DriveInfo(getinfo);
            string drivety = drinfo.DriveType.ToString(); //this for copy to usb drive
            {

                MessageBox.Show(" The File is copy To " );

            }
        }

        // this is for copy from usb drive to C drive
        private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
        {

        }
    }

}

0 个答案:

没有答案