You could create a class level string variable holding the current path. Then set this variable to whatever path has been selected in the OpenFileDialog.
Then, in the refresh handler, apply your refresh logic to stored path.
private string thePath;
public async void OpenFileBtn_ClickAsync(object sender, EventArgs e)
{
using(OpenFileDialog ofd = new OpenFileDialog() { Filter = "Text File|*.txt", Multiselect = false })
{
if (ofd.ShowDialog() == DialogResult.OK)
{
thePath = ofd.FileName;
Refresh();
}
}
}
private void RefreshBtn_Click(object sender, EventArgs e)
{
Refresh();
}
private void Refresh()
{
using (StreamReader rd = new StreamReader(thePath))
{
string[] lines = rd.ReadToEnd().Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
ReaderRichTxtBox.Text = lines[lines.Length - 1];
}
}