.net string类型的图片路径能复制图片么?
string tp = "" + T_KQ_xs.Rows[0]["photo_path2"].ToString().Trim() + "";if (tp != "")
{
FileUpload fl = new FileUpload();
tp = fl.FileName;
string file = Path.GetFileName(tp);
string tag = @"E:\SEA\Magzine\pic\" + file;
//创建文件夹
if (!System.IO.Directory.Exists(@"E:\SEA\Magzine\pic"))
{ // 目录不存在,建立目录
System.IO.Directory.CreateDirectory(@"E:\SEA\Magzine\pic");
}
System.IO.File.Copy(fl.FileName, tag);
file = tag;
}
else
{
}
------------------------------------------------------------------------------------------------------
tp\\是图片路径
我怎么不能复制图片啊? --------------------编程问答--------------------
ile.Copy(源文件地址,目标地址, true(为true是覆盖同名文件));
/// <summary>
/// 从一个目录将其内容移动到另一目录
/// </summary>
/// <param name="p">源目录</param>
/// <param name="p_2">目的目录</param>
private void MoveFolderTo(string p, string p_2)
{
//检查是否存在目的目录
if (!Directory.Exists(p_2))
Directory.CreateDirectory(p_2);
//先来移动文件
DirectoryInfo info = new DirectoryInfo(p);
FileInfo[] files = info.GetFiles();
foreach (FileInfo file in files)
{
File.Copy(param name="p“,Path.Combine(p_2, file.Name), true(为true是覆盖同名文件)); //复制文件
}
}
参考
http://blog.csdn.net/ou_yangpengfei/article/details/5874823
http://hi.baidu.com/%B6%E0%B0%D9%B6%E0%B6%C8%D0%D6%B5%DC/blog/item/b897a59a10424c056f068c63.html
补充:.NET技术 , ASP.NET