SoftwareSavant
SoftwareSavant

Reputation: 9747

Getting Paths from Config file in WPF

I want to be able to change directories that I use for a program (I am moving files from one directory to another and also commiting to SVN). I want to be able to change the directories relatively quickly, but also, these directories are more or less set. The directories might changes once or twice every six months or so. So I don't want to keep throwing it into a command line application, and I also don't want to have to recompile this application everytime I want to change the paths... How can I use a config file in WPF to get and set the paths to the appropriate files and directories like in an ASP.net application or a WCF service?

Thanks.

Upvotes: 0

Views: 1363

Answers (1)

MethodMan
MethodMan

Reputation: 18843

you can try this ... In you app.config change your appsetting to

<applicationSettings>
    <WpfApplication1.Properties.Settings>
        <setting name="appsetting" serializeAs="String">
            <value>c:\testdata.xml</value>
        </setting>
    </WpfApplication1.Properties.Settings>
</applicationSettings>

Then in code-behind

string xmlDataDirectory = WpfApplication1.Properties.Settings.Default.appsetting.ToString()

Upvotes: 1

Related Questions