问题
I would like to copy the file from source to destination directory. I heard that it is best to do this with a FileStream in case it gets modified later / accessed later.
I am using C# 2.0 and .NET 2.x.
I don't need to determine if the file is open or not or read/write or not. I just need to copy it as is, I have already determined that the file has stopped growing (check every 4 seconds) so that is 'good enough' in my situation.
So should I use MemoryStream or FileStream or File.Copy(..) and How?
回答1:
Use: File.Copy(..)
How: See the documentation. Also, I recommend checking out the Path class.
来源:https://stackoverflow.com/questions/4959349/is-filestream-the-safest-way-to-copy-a-file-vs-file-copy