File.Copy Question
-
I have a file that is being written to using stream writer. The file is written in frequent, random intervals. If I were to use a seperate application to grab a copy of this file (using File.Copy), would there be a chance the two applications would collide, while trying to perform operations on the same file? Or is the File.Copy method independant of whether the file is in use.. meaning I'd get the most recent copy from the last stream writer update? Any help would be appreciated!
-
I have a file that is being written to using stream writer. The file is written in frequent, random intervals. If I were to use a seperate application to grab a copy of this file (using File.Copy), would there be a chance the two applications would collide, while trying to perform operations on the same file? Or is the File.Copy method independant of whether the file is in use.. meaning I'd get the most recent copy from the last stream writer update? Any help would be appreciated!
cmarcus wrote:
have a file that is being written to using stream writer. The file is written in frequent, random intervals. If I were to use a seperate application to grab a copy of this file (using File.Copy), would there be a chance the two applications would collide, while trying to perform operations on the same file?
Assuming the stream writer has only locked the file for write operations (i.e. read operations are still allowed), then there should be no problem with the other application using File.Copy. It is essentially only reading the file.
cmarcus wrote:
Or is the File.Copy method independant of whether the file is in use.. meaning I'd get the most recent copy from the last stream writer update?
It will get the version that was last updated by stream writer as a result of flushing the buffer.