FileIO.FileSystem.CopyFile () vs System.IO.File.Copy ()

I have a couple of questions about the difference between these two classes and these specific methods, FileIO.FileSystem.CopyFile () and System.IO.File.Copy ()

At the simplest level, both of them do the same when they are overloaded with source files, destinationFile and bool set to true for rewriting. Eg

FileIO.FileSystem.CopyFile(source, destination, True) System.IO.File.Copy(source, destination, True) 

My two questions are:

  • What is the difference between overload metric 2 because I cannot find (or maybe I missed the point) anything on the MSDN website.
  • How do you (the kind person in charge) know the differences if this is not in the MSDN documentation?
+7
source share
4 answers

The VisualBasic version, after some checks, calls System.IO.File.Copy, and I find this with dotPeek, dotPeek is the .NET decompiler.

+2
source

A quick look at Microsoft.VisualBasic.dll in the reflector shows that FileIO.FileSystem.Copy simply passes File.Copy after performing several health checks (such as a file, a directory) and creating a destination directory, if necessary.

+7
source

The only difference I see is that they have the potential to raise a different list of exceptions - and I found that I'm afraid by reading the MSDN documentation: o)

+1
source

After my own research, he seems to be doing something that is not documented.

FileIO.FileSystem.CopyFile(source, destination, true) will create a folder if it does not exist, where System.IO.File.Copy(source, desintation, true) does not and throws an exception.

It also appears that when using FileIO.FileSystem.CopyFile(source, destination, true) link remains in memory, so when you try to delete a new folder or file, an exception is generated "... is already being used by another process."

0
source

All Articles