I am facing a problem that prevents me from progressing in my current project.
When loading the form, I would like to display "username - login - DateTime" in a RichTextBox. But since I recently changed the app design to dark theme, I need the text to be white. The text of this RichTextBox must be saved in a file so that the logs do not disappear each time the application is closed.
Here is the code of the form load method:
private void Form1_Load(object sender, EventArgs e)
{
txtUsersLogViewer.LoadFile(PATH_USER_LOG_FILE);
txtUsersLogViewer.SelectionColor = Color.White;
txtUsersLogViewer.AppendText(Environment.UserName + " - login" + DateTime.Now + Environment.NewLine);
}
At the first launch of the application, the text is displayed in white:

Now if I close the app and relaunch it, the new login text shows in black:

Then, the text is displayed in black each time the application is launched. This RichTextBox contains many more logs than just the logins, even texts in red and green, but it is only the login text that is displayed when the application loads that is the problem.
Since I always use the same method to change the text color and it's only that login text that doesn't work properly, I assumed that the problem might be with the file load. I tried commenting out the line that loads the .rtf file to see how the app behaved. And the text actually displays in white every time.
After that, I simply uncommented the line that loads the file and relaunched the app with the original code, and the app now behaves exactly how I wanted it to, without me changing a single line of code.
Correct result without having modified anything:

After that, if I clean and rebuild the solution, the text only shows as white again on the first launch of the application. And if I comment out the line, launch the application, close the application and uncomment the line again, the application will work temporarily until the next rebuild of the solution.
If you have a solution, it will help me a lot.