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;
}
}
}