移动文件夹

实现效果:

  

知识运用:

  DirectoryInfo类的MoveTo方法

  public void MoveTo (string destDirName)

实现代码:

        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                DirectoryInfo Dinfo=new DirectoryInfo(textBox1.Text);
                string strPath = textBox2.Text + textBox1.Text.Substring(
                    textBox1.Text.LastIndexOf("\")+1,textBox1.Text.Length-textBox1.Text.LastIndexOf("\")-1);
                Dinfo.MoveTo(strPath);
            }
            catch{}
        }
原文地址:https://www.cnblogs.com/feiyucha/p/10238474.html