3
Reply

file copy issue in c#

Stefan Cazacu

Stefan Cazacu

10 years ago
2k
I'm using "System.IO.File.Copy(recovery, set, true);" to copy recovery.txt over set.txt
The problem is, i think, the file is still in use when I attempt to further alter it. (the compiler throws an exception)
I've had a similar issue when using StreamWriter, however that was fixed by using writerObj.Close(). Is there anything similar for system.io?
This is probably an easy fix, however, i couldn't find a fix on msdn. Using google i must not be phrasing the question right as the only results include StreamWriter/StreamReader

EDIT:
I think i've managed to pinpoint the issue. After i copy the backup of set.txt i load the new values from the file and that seems to keep the file opened. The way i load values off the file is: use StreamReader to go through the file line by line and save numeric values in an array. Then i assign each member of the array to a functional parameter. My best guess is that somehow the functional parameters are still linked to the text file. Any suggestions?

Answers (3)