文件复制的问题。

feng8317 2009-03-19 02:17:23
我想把 aa文件夹下某几个文件复制到BB文件夹下面
File.Copy(strCsvfile, strCsvfileCopypath)
strCsvfile: aa文件夹下某个文件名。
strCsvfileCopypath bb文件夹的路径。
...全文
60 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
feng8317 2009-03-19
  • 打赏
  • 举报
回复
搞定了。后面一个不能是文件夹的。要文件才行。
feng8317 2009-03-19
  • 打赏
  • 举报
回复
这段话,为什么运行到File.Create(path)就出错呢
难道我visual studio安装的时候不是管理者的缘故吗。但是我现在已经把它改成管理者了啊。
怎么还会是这样的。
cppfaq 2009-03-19
  • 打赏
  • 举报
回复
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());
}
}
}
kingtiy 2009-03-19
  • 打赏
  • 举报
回复
可以呀。这样是可以实现的。
trCsvfileCopypath 可以带文件名,就会提示覆盖文件与否

111,126

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

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