lianpiau 0 Junior Poster

I want to set text file location in app.config

Something like these(below code is use to store database location)

<?xml version="1.0"?>
<configuration>
    <configSections>
    </configSections>
    <connectionStrings>
		<add name="MyDBConnectionString" connectionString="Data Source=LIANPIAU\SQLEXPRESS;Initial Catalog=DiningChair;Integrated Security=True"
            providerName="System.Data.SqlClient" />
        <add name="MyDBConnectionString_PO" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=&quot;\\Shlim\wansern prog\PODiningA.mdb&quot;"
            providerName="System.Data.OleDb" />
        <add name="MyDBConnectionString_Loading" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=&quot;C:\LorryBook.mdb&quot;"
            providerName="System.Data.OleDb" />
        <add name="MyDBConnectionString_ReportSystem" connectionString="Data Source=SHLIM;Initial Catalog=Report;Integrated Security=True"
            providerName="System.Data.SqlClient" />
		<add name="DiningMould" connectionString="Data Source=SHLIM;Initial Catalog=DiningMould;Integrated Security=True"
            providerName="System.Data.SqlClient" />
		<add name="MyDBConnectionString_Access" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=&quot;\\Wdsharespace\Wansern_System\Wansern_Foam\Instyle Sofa\Instyle_Sofa.mdb&quot;"
            providerName="System.Data.OleDb" />
		<add name="EventLog" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=&quot;\\Wdsharespace\Wansern_System\Wansern_Foam\Instyle Sofa\Event_Log\Log.txt&quot;"
            providerName="System.Data.OleDb" />
    </connectionStrings>
	<system.windows.forms jitDebugging="true"/>
                                                                                  
	</configuration>

so that I call the location to use

<?xml version="1.0"?>
<configuration>
    <configSections>
    </configSections>
    <connectionStrings>
		<add name="MyDBConnectionString" connectionString="Data Source=LIANPIAU\SQLEXPRESS;Initial Catalog=DiningChair;Integrated Security=True"
            providerName="System.Data.SqlClient" />
        <add name="MyDBConnectionString_PO" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=&quot;\\Shlim\wansern prog\PODiningA.mdb&quot;"
            providerName="System.Data.OleDb" />
        <add name="MyDBConnectionString_Loading" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=&quot;C:\LorryBook.mdb&quot;"
            providerName="System.Data.OleDb" />
        <add name="MyDBConnectionString_ReportSystem" connectionString="Data Source=SHLIM;Initial Catalog=Report;Integrated Security=True"
            providerName="System.Data.SqlClient" />
		<add name="DiningMould" connectionString="Data Source=SHLIM;Initial Catalog=DiningMould;Integrated Security=True"
            providerName="System.Data.SqlClient" />
		<add name="MyDBConnectionString_Access" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=&quot;\\Wdsharespace\Wansern_System\Wansern_Foam\Instyle Sofa\Instyle_Sofa.mdb&quot;"
            providerName="System.Data.OleDb" />
		<add name="EventLog" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=&quot;\\Wdsharespace\Wansern_System\Wansern_Foam\Instyle Sofa\Event_Log\Log.txt&quot;"
            providerName="System.Data.OleDb" />
    </connectionStrings>
	<system.windows.forms jitDebugging="true"/>
                                                                                  
	</configuration>

I want store text file location because I want to use it for my log event file

System.IO.StreamWriter writer = new System.IO.StreamWriter("\\\\Wdsharespace\\Wansern_System\\Wansern_Foam\\Instyle Sofa\\Event_Log\\AddOrder.txt", true);
                    writer.Write(DateTime.Now.ToString() + " ");
                    writer.Write("[Add Order to PDC] ");
                    writer.Write("[PONO]" + txtPONO.Text + " ");
                    writer.Write("[Item]" + txtItemM.Text + " ");
                    writer.Write("[User]" + lblUserName.Text + " ");
                    writer.Write("[Del.Date]" + dtpDeliveryDate.Value + " ");
                    writer.Write("[Customer]" + cboCustomer.Text + " ");
                    writer.Write("[Model]" + cboModel.Text + " ");
                    writer.Write("[FGrade]" + cboFGrade.Text + " ");
                    writer.Write("[Size]" + cboThk.Text + cboT_Unit.Text + " X ");
                    writer.Write(cboSize.Text + cboW_Unit.Text + " X ");
                    writer.Write(cboLength.Text + cboL_Unit.Text + " ");
                    writer.WriteLine("[Qty]" + txtQty.Value);

                    writer.Close();
                    writer.Dispose();
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.