Reputation: 8451
I have a couple of questions about the difference between this 2 classes and these specific methods, FileIO.FileSystem.CopyFile() and System.IO.File.Copy()
At the simplest level, they both do the same thing when overloaded with sourceFile, destinationFile and bool set to true to overwrite. EG
FileIO.FileSystem.CopyFile(source, destination, True)
System.IO.File.Copy(source, destination, True)
My two questions are
Upvotes: 8
Views: 15886
Reputation: 8451
After my own research, it does appear to do something not documented.
FileIO.FileSystem.CopyFile(source, destination, true)
will create a folder if it doesn't exist, where as System.IO.File.Copy(source, desintation, true)
doesn't and throws an exception.
It also appears that when using FileIO.FileSystem.CopyFile(source, destination, true)
the reference remains in memory, so when trying to delete the new folder or file, an exception is thrown "...already in use by another process".
Upvotes: 0
Reputation: 20693
VisualBasic version after some checks calls System.IO.File.Copy, and I find that out by using the dotPeek, dotPeek is .NET decompiler.
Upvotes: 3
Reputation: 24372
A quick look at Microsoft.VisualBasic.dll in reflector shows FileIO.FileSystem.Copy
does just hand over to File.Copy
after doing a couple of sanity checks (file, directory exists for example) and creating the destination directory if needed.
Upvotes: 8
Reputation: 6390
The only difference I can see is that they have potential to raise a different list of exceptions - and I discovered that, I'm afraid, by reading the MSDN documentation :o)
Upvotes: 1