我拷贝文件的时候遇到一个很奇怪的问题!
明明C:\\Users\\xxl\\Documents\\test 文件夹下什么文件都没有。但是报错说:C:\\Users\\xxl\\Documents\\test\\aa.txt已经存在。我是Win7系统。
string _localDirectory = System.Environment.CurrentDirectory.ToString();
path="C:\\Users\\xxl\\Documents\\test\\aa.txt";File.Copy(_localDirectory + "\\aa.txt", path);
明明C:\\Users\\xxl\\Documents\\test 文件夹下什么文件都没有。但是报错说:C:\\Users\\xxl\\Documents\\test\\aa.txt已经存在。我是Win7系统。
string _localDirectory = System.Environment.CurrentDirectory.ToString();
path="C:\\Users\\xxl\\Documents\\test\\aa.txt";File.Copy(_localDirectory + "\\aa.txt", path);
file.exits(path) 目标目录下文件存在则询问用户是否覆盖
File.Copy(Path.Combine(_localDirectory ,"aa.txt"), path,true);
否则不复制。
但是我C:\\Users\\xxl\\Documents\\test 文件夹下是空的!string _localDirectory = System.Environment.CurrentDirectory.ToString();
//值是D:\MProjects\TestCopyFile\Main\bin\Debug\Config.xml
//这个Config.xml是有的!
string path = "C:\\aa.txt";
File.Copy(Path.Combine(_localDirectory, "aa.txt"), path, true);
这个是没错的 ,楼主不行重启一下机器吧呵呵