public static WeatherApiConfig GetApiConfig() { try { DirectoryController directory = new DirectoryController(); using (StreamReader reader = new StreamReader(directory.GetConfigPath("weatherAPI.json"))) { string json = reader.ReadToEnd(); return(JsonConvert.DeserializeObject <WeatherApiConfig>(json)); } } catch (FileNotFoundException) { MessageBox.Show("File 'weatherAPI.json' not found", "Something is wrong", MessageBoxButtons.OK, MessageBoxIcon.Error); return(null); } catch (DirectoryNotFoundException) { MessageBox.Show("File 'weatherAPI.json' not found", "Something is wrong", MessageBoxButtons.OK, MessageBoxIcon.Error); return(null); } }