Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 539
  • Last Modified:

modify app.config file

Hi Guys,

I am working on a project where I need to build 30 machines with a specific application.

The app.config file references the machine name (developers have been lazy and not done waht we want and have this auto populate with system.environment.machinename which is being addresses)

instead I need to populate this in the app.config file along with a few other lines.

my current app.config file looks like this

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <appSettings>
        <add key="DeviceName" value="panasoncic cf-h2" />
    <add key="ServerName" value="http://myurl.com" />
    <add key="Username" value="222" />
    <add key="Password" value="111" />
    <add key="DeleteAfterSend" value="N" />
    <add key="ApproveBeforeSend" value="N" />
    <add key="AutoApprove" value="N" />
    <add key="UseSSL" value="Y" />
    <add key="AutoSync" value="Y" />
    <add key="SyncOccurances" value="-1" />
    <add key="PurgeDays" value="-1" />
    <add key="RequireLogon" value="N" />
    <add key="PrinterPort" value="" />
    <add key="PrinterBTPort" value="" />
    <add key="GPSPort" value="" />
    <add key="GPSBaudRate" value="9600" />
  </appSettings>
</configuration>

Open in new window


i need to modify the username, password, url and device name..... and will then deploy the app.config file to the specified machine.

ive been looking on here but cant find an asnwer that is a complete or makes sense..

I have been able to read the values easily, but am struggling to write as this is new teritory for me.

any and all help will be very much appreciated.

Thanks

Simon
0
SimonPrice33
Asked:
SimonPrice33
  • 4
1 Solution
 
Jaime OlivaresSoftware ArchitectCommented:
Hi, how are you reading the config file?
There is not an easy way to modify an xml, as far as I know. You have to rewrite it entirely.
0
 
SimonPrice33Author Commented:
Hi i have imported system.configuration.confurationsettings

Then have a a text field called txtmachine

Txtmachinename.text  = appsettings("devicename")

Which readsit....

 Iwas thinking this morning that i would ave to rewrite the entire config again but as its simply just xml will write it with linq


Ill let you knownhowni get on
0
 
CodeCruiserCommented:
What happens if you try

appsettings("devicename") = Txtmachinename.text

?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
SimonPrice33Author Commented:
sorry... didnt see this comment...

i will test and come back to you... thats on a different machine to what im on at the moment
0
 
SimonPrice33Author Commented:
the modification of the config file crashes the application...  the deadline on this project has passed and i had to work it manually...

 thanks for your help guys
0
 
SimonPrice33Author Commented:
.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now