Reputation: 273
I just ran
File.Move(@"C:\sub1\file.xml", "file" + ".XMl"));
The file did dissappear from C:\sub1
. No error was thrown. Did the file go somewhere?
Upvotes: 4
Views: 231
Reputation: 186668
When directory is not specified, current one is used:
https://msdn.microsoft.com/en-us/library/system.io.file.move(v=vs.110).aspx
The sourceFileName and destFileName arguments can include relative or absolute path information. Relative path information is interpreted as relative to the current working directory. To obtain the current working directory, see 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"));
Upvotes: 8
Reputation: 593
It moved to the app working directory. Usually it is where executable file located
Upvotes: 3