I\'ve been working on this small piece of code that seems trivial but still, i cannot really see where is the problem. My functions do a pretty simple thing. Opens a file, c
Sounds like an external process (AV?) is locking it, but can't you avoid the problem in the first place?
private static bool modifyFile(FileInfo file, string extractedMethod, string modifiedMethod)
{
try
{
string contents = File.ReadAllText(file.FullName);
Console.WriteLine("input : {0}", contents);
contents = contents.Replace(extractedMethod, modifiedMethod);
Console.WriteLine("replaced String {0}", contents);
File.WriteAllText(file.FullName, contents);
return true;
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
return false;
}
}