The question says it all really.
What are the differences between these two methods that appear to carry out exactly the same function?
Is there guidance to say which should be used or are there conditions when you may use either?
The question says it all really.
What are the differences between these two methods that appear to carry out exactly the same function?
Is there guidance to say which should be used or are there conditions when you may use either?
I believe they have near-identical functionality. Most people I've seen would prefer to use the latter, because "MyComputer." is a VB.NET-only construct, whereas File.Move is used in both C# and VB.NET. This makes it easier to get help, and easier for C# coders to read the VB.NET code and vice-versa.
I haven't checked My.Computer.FileSystem.MoveFile, but you can state if they are differences moving html files with associated images directories., because File.Move just move the file, but doesn't move the associated directory
The FileSystem.MoveFile
has some more options than File.Move
, like for example optionally showing a progress dialog, and creating the destination folder if it doesn't exist.
If you just want to move or rename a file, the File.Move
method will be called in the end whichever you use, so calling it directly means slightly less overhead.