You should use the property FileName from the OpenFileDialog to retrieve the name of your file
openWork.CheckFileExists = true;
if (openWork.ShowDialog() == DialogResult.OK)
{
// Check if you really have a file name
if(openWork.FileName.Trim() != string.Empty)
{
using (StreamReader r = new StreamReader(openWork.FileName))
{
string json = r.ReadToEnd();
Person items = JsonConvert.DeserializeObject<Person>(json);
}
}
}
Also I have added a CheckFileExists
property to true to display a warning if the user specifies a file name that does not exist.