您的位置:首页 > 其它

复制文件到指定的文件夹

2011-09-07 17:41 232 查看
using System;
using System.Windows.Forms;
using System.IO;

namespace Common
{
public class FileHelper
{
/// <summary>
/// 复制文件到指定路径
/// </summary>
/// <param name="sourcePath">原文件的路径</param>
/// <returns></returns>
public static bool CopyFileTo(string sourcePath)
{
//文件夹选择框
FolderBrowserDialog folderBrowser = new FolderBrowserDialog();
folderBrowser.Description = "请选择保存路径";

if (folderBrowser.ShowDialog() == DialogResult.OK)
{
string destinationPath = Path.Combine(folderBrowser.SelectedPath,
Path.GetFileName(sourcePath));
try
{
File.Copy(sourcePath, destinationPath);
return true;
}
catch (Exception)
{
return false;
}
}

return false;
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: