Change AppSettings in App.Config of another Exe

I have a C # .NET Console EXE application with app.config indicating several ApplicationSettings parameters used as parameters.

I have an additional separate (Windows Forms) exe (located in the same directory) to allow the ApplicationSettings used by the first exe to be modified by the user.

What is the cleanest way to change the first exe app.config from the second exe?

Thanks.

+3
source share
2 answers

you can use

public static Configuration OpenExeConfiguration(
    string exePath
)

MSDN Link

+2
source

Using:

Configuration cfg = ConfigurationManager.OpenExeConfiguration(path_to_exe_file_of_second_app);
// do whatever you need with that configuration
cfg.Save();

, OpenExeConfiguration exe , .

+2

Source: https://habr.com/ru/post/1710146/


All Articles