PDA

View Full Version : خواندن و تغییر در فایل config از طریق کد



sg.programmer
یک شنبه 01 دی 1392, 13:25 عصر
سلام
چطور میشه فایل config را از داخل کد سی شارپ مقادیرش را خوند و از آن استفاده و یا تغییر و.. داد
مثل کوچیک چطور پورت اش را خوند و در برنامه تغییر داد؟

نمونه ای از فایل کانفیگ

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service name="Server.Chat" behaviorConfiguration="ChatService">
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8080/Chat/Chater"/>
</baseAddresses>
</host>
<endpoint address="" binding="netTcpBinding" bindingConfiguration="Binding1" contract="Server.ISendChatService">
</endpoint>
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/>
</service>
</services>

<bindings>
<netTcpBinding>
<binding name="Binding1" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10" maxReceivedMessageSize="65536">
<security mode="None">
<message clientCredentialType ="UserName"/>
</security>
</binding>
</netTcpBinding>
</bindings>

<behaviors>
<serviceBehaviors>
<behavior name="ChatService">
<serviceMetadata httpGetEnabled="False"/>
<serviceDebug includeExceptionDetailInFaults="False"/>
</behavior>
</serviceBehaviors>
</behaviors>

</system.serviceModel>
</configuration>

abbas.oveissi
یک شنبه 01 دی 1392, 15:53 عصر
میتونی از این لینک ها استفاده بکنی :
http://stackoverflow.com/questions/2400097/reading-from-app-config-file
http://stackoverflow.com/questions/10864755/adding-and-reading-from-a-config-file
احتمالا توی همین فروم هم قبلا در موردش بحث شده باشه.