我刚跑了
File.Move(@"C:\sub1\file.xml", "file" + ".XMl"));
该文件确实从C:\sub1中消失了。没有抛出错误。文件哪里去了吗?
发布于 2017-03-03 19:26:12
如果未指定目录,则使用当前目录:
https://msdn.microsoft.com/en-us/library/system.io.file.move(v=vs.110).aspx
sourceFileName和destFileName参数可以包括相对路径信息或绝对路径信息。相对路径信息被解释为相对于当前工作目录。若要获取当前工作目录,请参阅GetCurrentDirectory。
Environment.CurrentDirectory = @"C:\Test";
// C:\sub1\file.xml will be moved to C:\Test\file.XMl
File.Move(@"C:\sub1\file.xml", "file" + ".XMl"));发布于 2017-03-03 19:21:27
它移到了应用程序工作目录。通常是可执行文件所在的位置。
发布于 2017-03-03 19:21:17
是的,它在你的运行文件夹里。
https://stackoverflow.com/questions/42586758
复制相似问题