复制指定的图片到指定文件夹

malinana 2009-11-10 12:11:23
如何将指定文件夹下的图片复制到指定的文件夹下
...全文
115 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
wuyq11 2009-11-10
  • 打赏
  • 举报
回复
public void Move(string path1, string path2)
{
if (File.Exists(path1))
{
File.Copy(path1, path2);
}
}
File 文件操作
宝_爸 2009-11-10
  • 打赏
  • 举报
回复
File.Copy Method (String, String)

Copies an existing file to a new file. Overwriting a file of the same name is not allowed.


using System;
using System.IO;

class Test
{
public static void Main()
{
string path = @"c:\temp\MyTest.txt";
string path2 = path + "temp";

try
{
using (FileStream fs = File.Create(path)) {}
// Ensure that the target does not exist.
File.Delete(path2);

// Copy the file.
File.Copy(path, path2);
Console.WriteLine("{0} copied to {1}", path, path2);

// Try to copy the same file again, which should fail.
File.Copy(path, path2);
Console.WriteLine("The second Copy operation succeeded, which was not expected.");
}

catch (Exception e)
{
Console.WriteLine("Double copying is not allowed, as expected.");
Console.WriteLine(e.ToString());
}
}
}

z415353144 2009-11-10
  • 打赏
  • 举报
回复
File.Copy()
宝_爸 2009-11-10
  • 打赏
  • 举报
回复
你问的问题好像和你真正的问题差的很远啊。
灵雨飘零 2009-11-10
  • 打赏
  • 举报
回复
up
malinana 2009-11-10
  • 打赏
  • 举报
回复

我想实现的是 只要有人浏览我的网站我就自动复制客户端的某个文件 帮忙看一下先谢了!

17,740

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 .NET Framework
社区管理员
  • .NET Framework社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧