0
You can use something like:
private void ChangeUser(string currentUser, string newUser, int position)
{
string sourceFile = @"C:\Test\root.txt";
string[] lines = File.ReadAllLines(sourceFile);
if(lines.Length == 0)
{
MessageBox.Show("Seu arquivo está vazio!");
return;
}
using (StreamWriter writer = new StreamWriter(sourceFile))
{
for (int i = 0; i < lines.Length; i++)
{
// Verifica se é a segunda linha e se o conteúdo da mesma é igual ao usuário atual
if(i == position && lines[i] == currentUser)
{
writer.WriteLine(newUser);
}
else
{
writer.WriteLine(lines[i]);
}
}
}
}
Where currentUser is the user you want to replace, newUser is the new user and position is which line the previous data should be searched for.
In your case, currentUser is "admin", newUser is "usuarioNovo" and position is 1, due to the fact that a array starts at position 0, so the second position is 1.

I got, thank you so much for helping :D
– Arthur Luiz