dnclem
dnclem

Reputation: 2838

C# Load Application Settings from other project?

I have a bunch of property settings saved in an application (WinForms btw, I have never touched WPF) in a project, and I'm re-writing that project again due to messy coding. The problem is, there are around 50 settings (the settings which you can see from Project Properties and the Settings option) in that project and I don't know how to copy them to the new project. Is there a way to do this or will I have to add them all over again?

Upvotes: 1

Views: 3804

Answers (4)

WavJamB
WavJamB

Reputation: 21

  1. Go to the Properties directory of the project with the settings you want.
  2. Copy the Settings.Designer.cs and Settings.settings files.
  3. Go to the Properties directory of the new project and paste them.
  4. Open the Settings.Designer.cs (I use notepad for this) and change the namespace to match your new project.
  5. The settings should now be available in your new project. You can view them by clicking on the Settings.settings file in the Solution Explorer.

Upvotes: 2

Roman Pokrovskij
Roman Pokrovskij

Reputation: 9766

In the Solution Explorer open $MyPojectName\Properties\Settings.settings with XML Editor (use Open With... context menu option) and copy them where you want.

And if you want to override another project's settings file be ready to renew root element's GeneratedClassNamespace attribute.

Upvotes: 3

Hector Correa
Hector Correa

Reputation: 26690

The settings are saved in two settings files (settings.settings and settings.designer.cs)

You can just copy these files to your new project and overwrite the empty ones with the ones from the previous project.

You might need to edit the files before copying them to make sure the namespace matches the namespace on the new project.

Upvotes: 4

Genius
Genius

Reputation: 1782

just copy the app.config file to destination project folder

Upvotes: -2

Related Questions