i am writing a simple folder synchronization app.
Therefore i want at the time a file is created in the source folder it should be
copied to the destination.
My question is : how can i avoid errors when trying to read the source file, since another process might want to write to it ? Should i read the file in Read Write Share mode or is a simple System.IO.File.Copy enough ?
Thanks !
File Copy will lock the file while it is being copied.
If it wasn’t locked, the file could be corrupted during the copy by another process
So, when you start the copy process there are two possibilities:
and locks the source file.
exception.