Violação de compartilhamento IOException ao ler e gravar no arquivo C #

Aqui está o meu código:

public static TextWriter twLog = null;
private int fileNo = 1;
private string line = null;

TextReader tr = new StreamReader("file_no.txt");
TextWriter tw = new StreamWriter("file_no.txt");
line = tr.ReadLine();
if(line != null){
    fileNo = int.Parse(line);
    twLog = new StreamWriter("log_" + line + ".txt");
}else{
    twLog = new StreamWriter("log_" + fileNo.toString() + ".txt");  
}
System.IO.File.WriteAllText("file_no.txt",string.Empty);
tw.WriteLine((fileNo++).ToString());
tr.Close();
tw.Close();
twLog.Close();

Isso lança esse erro:

IOException: violação de compartilhamento no caminho C: \ Users \ Water Simulation \ file_no.txt

O que estou tentando fazer é simplesmente abrir um arquivo com o nome log_x.txt e pegar o "x" do arquivo file_no.txt. Se o arquivo file_no.txt estiver vazio, faça o nome do arquivo de log log_1.txt e escreva "fileNo + 1" para file_no.txt.After um novo programa inicia o novo nome do arquivo de log deve ser log_2.txt.Mas estou recebendo esse erro e eu não conseguia entender o que estou fazendo de errado.Graças de ajuda.

questionAnswers(3)

yourAnswerToTheQuestion