I'm getting a log error that reads "The process cannot access the file because it is being used by another process". I don't see how this could be the case, my strategy is running only on one instrument. The following code causes the error:
string path = Cbi.Core.UserDataDir.ToString() + "17Closes.inp";
string path2 = Cbi.Core.UserDataDir.ToString() + "TEMP17.txt";
//create file info
FileInfo fi1 = new FileInfo(path);
FileInfo fInfo = new FileInfo(path);
// replace the file.
fInfo.Replace(path, path2, false);
if (!fi1.Exists)
{
//Create a file to write to.
using (StreamWriter sw = fi1.CreateText())
{
//Do stuff
}
}
I'm simply trying to delete a file before I create a new one again because I don't want to append to an existing file.

Comment