none
How to write App.config file store Multiple Username and Password and Read all in Runtime? RRS feed

Answers

  • Please keep in mind that, by default, app.config is a directory that cannot be written to. Is there a particular reason why you're trying to store this data in the config file? A database (for shared configuration) or a user config (for per user configuration) is the better option.

    Michael Taylor http://www.michaeltaylorp3.net

    Thursday, January 18, 2018 3:12 PM
    Moderator

All replies

  • Hi Vishal,

    You need to use the "ConfigurationManager" under "System.Configuration" to access the app.config files value. If you are using winform then put the code into under "form_load" method. Please look into the below code. Hope this helps you.

    var userName = ConfigurationManager.AppSettings["users"];
    var userPassword = ConfigurationManager.AppSettings["Passwords"];


    Thanks,
    Sabah Shariq

    [If a post helps to resolve your issue, please click the "Mark as Answer" of that post or click Answered"Vote as helpful" button of that post. By marking a post as Answered or Helpful, you help others find the answer faster. ]


    Thursday, January 18, 2018 11:40 AM
    Moderator
  • I don't know my app.config is write or wrong ? how it is write i will ask
    Thursday, January 18, 2018 1:20 PM
  • Please keep in mind that, by default, app.config is a directory that cannot be written to. Is there a particular reason why you're trying to store this data in the config file? A database (for shared configuration) or a user config (for per user configuration) is the better option.

    Michael Taylor http://www.michaeltaylorp3.net

    Thursday, January 18, 2018 3:12 PM
    Moderator
  • I don't know my app.config is write or wrong ? how it is write i will ask

    Hi Vishal,

    The app.config is an XML file with many predefined configuration sections available and support for custom configuration sections.

    So you can write the app.config file with the same syntax of XML, and search the element with the solution provided by Sabah.

    Regards,

    Stanly


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, January 19, 2018 6:40 AM