views:

590

answers:

3

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?

+1  A: 

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.

GWLlosa
but C# can also use the "My" namespace, correct?
Camilo Martin
I haven't seen the My namespace accessible from C# at all. There may be some way to get a reference to it, but its certainly atypical.
GWLlosa
A: 

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

Jhonny D. Cano -Leftware-
+1  A: 

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.

Guffa