Finding Configuration Files
Here’s a useful technique for finding the location of configuration files.
Each AppDomain has a base directory from which it loads assemblies – when you double click a WinForms or WPF application, the new process that starts up has an AppDomain whose base directory is the directory in which your exe is located.
This makes it easy to locate any ancillary files that are deployed next to your assemblies:
1: string domainPath = AppDomain.CurrentDomain.BaseDirectory;
2: string xmlPath = Path.Combine(domainPath, "Resources\\Controller.Config");
3: 4: if (File.Exists(xmlPath))
5: {6: // Load and process configuration file here
7: ... 8: }Note that this technique assumes that the AppDomain will have a base directory that points to your application – while this is true for WinForms and WPF applications, “your mileage may vary” with ASP.NET and ASP.NET MVC.

Recent comments
4 weeks 15 hours ago
4 weeks 21 hours ago
4 weeks 1 day ago
4 weeks 1 day ago
8 weeks 1 day ago
9 weeks 16 hours ago
9 weeks 4 days ago
9 weeks 4 days ago
11 weeks 5 days ago
12 weeks 3 hours ago