-6

I have a config file in my C# windows project (e.g. text.Config).In this file I have sections like

<configuration>
  <configSections>

  </configSections>
  <FtpSettings>
    <add key="ftpURL" value=""/>
    <add key="ftpUserName" value=""/>
    <add key="ftpPassword" value=""/>
  </FtpSettings>
</configuration>

I am using 3.5 framework.

So can you tell me how can I read FtpSettings through this file?

I want all values within this section.

Can anyone give me exact code for this?Without string operations i need value of a particular key.

Thanks in advance.

  • 2
    what have you tried? Show the code you have tried with any errors you may have gotten – BossRoss Jun 05 '14 at 09:00
  • 1
    Duplicate. Check this, [How to read a values from new section in web.config][1] [1]: http://stackoverflow.com/questions/6329114/how-to-read-a-values-from-new-section-in-web-config – Srinivasan MK Jun 05 '14 at 09:02

1 Answers1

1

Treat it as an XML file, and then you have many ways to read it.

  1. Use XmlTextReader
  2. Use LINQ to XML
  3. Take a look of others questions, like this one.
  4. Many other ways...
Community
  • 1
  • 1
  • not useful...we have to split string in this examples I need direct value of particular key.... – Parag Vasant Jun 05 '14 at 11:40
  • Yeah how dare you not code it all for him. @ParagVasant ALL of the stuff he gave you here is useful and a valid way of doing exactly what you're asking for. – tnw Jun 05 '14 at 13:24