码迷,mamicode.com
首页 > 移动开发 > 详细

[C#常用代码]如何把指定文件夹中的文件移动到指定的文件夹

时间:2014-09-25 22:56:48      阅读:274      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   io   ar   for   文件   sp   div   

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

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string strPath = Application.StartupPath +"\\"+ "path" + "\\";
            if (!Directory.Exists(strPath))
            {
                Directory.CreateDirectory(strPath);
            }
            string strFilePath = strPath + "a.xml";

            string strPathSuccess = Application.StartupPath +"\\"+ "pathSuccess" + "\\";
            if (!Directory.Exists(strPathSuccess))
            {
                Directory.CreateDirectory(strPathSuccess);
            }
            string strFilePathSuccess = strPathSuccess + "a.xml";
            //File.Move(strFilePath,strFilePathSuccess);
            //textBox1.Text="D:\wenjianjia\a.xml"
            File.Move(strFilePath, @textBox1.Text);
            MessageBox.Show("Success");
        }
    }
}

 

[C#常用代码]如何把指定文件夹中的文件移动到指定的文件夹

标签:style   blog   color   io   ar   for   文件   sp   div   

原文地址:http://www.cnblogs.com/beeone/p/3993552.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!