テキストファイルの行を1つ上に移動してから元のファイルに書き直そうとしていますが、何らかの理由でエラーが発生し、理解できないようです。
using (StreamReader reader = new StreamReader("file.txt"))
{
string line;
int Counter = 0;
while ((line = reader.ReadLine()) != null)
{
string filepath = "file.txt";
int i = 5;
string[] lines = File.ReadAllLines(filepath);
if (lines.Length >= i)
{
string tmp = lines[i];
lines[i] = lines[i-1];
lines[i-1] = tmp;
File.WriteAllLines(filepath, lines);
}
}
Counter++;
}