473,799 Members | 3,810 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

help to create app.config

Hi,
Could anyone help me with some info how to create app.config file.
I need to put code of directory info in there, Thank you very much!

DirectoryInfo di = new DirectoryInfo(" C:\\Vicky Development\\Fu ndExplorer\\
Index\\Copy of IntlIndex");
---------------------------------------------------------------------

I know in app.config may like below
---------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>

<configuratio n>

<appSettings>

<!-- User application and configured property settings go here.-->

<!-- Example: <add key="settingNam e" value="settingV alue"/> -->

<add key="reportingS ervice.ServerNa me" value="Http://Localhost" />
<!-- No ending "/" -->

<add key="connOperat ions.Connection String" value="Integrat ed
Security=SSPI;P ersist Security Info=False;Data Source=HIRST-IT1\
TEST;Initial Catalog=FundMan ager42205;" />

</appSettings>

</configuration>
------------------------------------------------------------------------
And in the code when I create Reader I do below

System.Configur ation.AppSettin gsReader appReader =

new System.Configur ation.AppSettin gsReader()
;

string connString = (string)appRead er.GetValue(

"connOperations .ConnectionStri ng",typeof
(string));

SqlConnection conn = new SqlConnection(c onnString);
------------------------------------------------------------------------

Here is begining part of the code
------------------------------------------------------------------
namespace dataReader

{

class Class1

{
[STAThread]

public static void Main(string[] args)

{

DirectoryInfo di = new DirectoryInfo(" C:\\Vicky Development\\Fu ndExplorer\\
Index\\Copy of IntlIndex");

// Get a reference to each file in that directory.

FileInfo[] fiArr = di.GetFiles();

int FundID=0;

int PeriodicityID = 0;;

string Ticker=null;

string currentLine = null;

//set up sql connection string

string myConnString= "workstatio n id=HIRST-IT1;packet size=4096;"+

"Integrated Security=SSPI;i nitial catalog=FundMan ager42205;"+ "Data
Source=HIRST-IT1\\TEST;"+

"persist security info=True";

// for each file in Directory, if TickerName match DB, load data

foreach (FileInfo fri in fiArr)

{

StreamReader sr = new StreamReader("C :\\Vicky Development\\Fu ndExplorer\\
Index\\Copy of IntlIndex\\"+fr i.Name);

//read the text file

//read the first row --header

currentLine = sr.ReadLine();

//read the second row contains data

currentLine = sr.ReadLine();

-
-
-
-
-
}

--
Message posted via http://www.dotnetmonster.com
Nov 17 '05 #1
2 15830
Hi,

First of all you cannot write the app.config file, it's open with a write
lock for the application, that's why you cannot modify it in your code.

what you can do is create another file to store the config you need to
change in your code (you could also use the registry ) to do this you can
use a simpler var_name=value approach or another xml file with a similar
struct than the app.config file then read it and parse in your program.
I prefer to use the first approach though.

Cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Vicky via DotNetMonster.c om" <fo***@nospam.D otNetMonster.co m> wrote in
message news:1b******** *************** *******@DotNetM onster.com...
Hi,
Could anyone help me with some info how to create app.config file.
I need to put code of directory info in there, Thank you very much!

DirectoryInfo di = new DirectoryInfo(" C:\\Vicky
Development\\Fu ndExplorer\\
Index\\Copy of IntlIndex");
---------------------------------------------------------------------

I know in app.config may like below
---------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>

<configuratio n>

<appSettings>

<!-- User application and configured property settings go
here.-->

<!-- Example: <add key="settingNam e" value="settingV alue"/> -->

<add key="reportingS ervice.ServerNa me" value="Http://Localhost" />
<!-- No ending "/" -->

<add key="connOperat ions.Connection String" value="Integrat ed
Security=SSPI;P ersist Security Info=False;Data Source=HIRST-IT1\
TEST;Initial Catalog=FundMan ager42205;" />

</appSettings>

</configuration>
------------------------------------------------------------------------
And in the code when I create Reader I do below

System.Configur ation.AppSettin gsReader appReader =

new
System.Configur ation.AppSettin gsReader()
;

string connString = (string)appRead er.GetValue(

"connOperations .ConnectionStri ng",typeof
(string));

SqlConnection conn = new SqlConnection(c onnString);
------------------------------------------------------------------------

Here is begining part of the code
------------------------------------------------------------------
namespace dataReader

{

class Class1

{
[STAThread]

public static void Main(string[] args)

{

DirectoryInfo di = new DirectoryInfo(" C:\\Vicky
Development\\Fu ndExplorer\\
Index\\Copy of IntlIndex");

// Get a reference to each file in that directory.

FileInfo[] fiArr = di.GetFiles();

int FundID=0;

int PeriodicityID = 0;;

string Ticker=null;

string currentLine = null;

//set up sql connection string

string myConnString= "workstatio n id=HIRST-IT1;packet size=4096;"+

"Integrated Security=SSPI;i nitial catalog=FundMan ager42205;"+ "Data
Source=HIRST-IT1\\TEST;"+

"persist security info=True";

// for each file in Directory, if TickerName match DB, load data

foreach (FileInfo fri in fiArr)

{

StreamReader sr = new StreamReader("C :\\Vicky Development\\Fu ndExplorer\\
Index\\Copy of IntlIndex\\"+fr i.Name);

//read the text file

//read the first row --header

currentLine = sr.ReadLine();

//read the second row contains data

currentLine = sr.ReadLine();

-
-
-
-
-
}

--
Message posted via http://www.dotnetmonster.com

Nov 17 '05 #2
Ignacio,

Thank you so much fo your reply.
I try to understand you said "you cannot write the app.config file
it's open with a write lock for the application"

I did modify a app.config file before to a different server and DB,when I
did testing, I have to uncheck the Read only to make the changes.
But I will create a new file as you suggested.
I noticed that it is common to put server, and DB info in app.config file
I did not see an example to put Directory or file Path in app.config,
Do you have any example? I could give a try similiar like server, and DB
info. Thanks!

DirectoryInfo di = new DirectoryInfo(" C:\\Vicky Development\\Fu ndExplorer\\
Index\\Copy of IntlIndex");

--
Message posted via http://www.dotnetmonster.com
Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1784
by: david | last post by:
I found my web.config file always in lock mode, when I tried to modify it, I ofter got "Can not create web.config" error. I had to reboot my machine, and before I accessed any site I can modify it. I think microsoft creates the ..NET structure so that user can modify config file easier without restart service. I am not sure why my web.config works like that? Could someone explain this to me? And is there a easier way I can modify the config...
25
2867
by: n3crius | last post by:
hi, i just got a web host with asp.net , seemed really cool. aspx with the c# or vb IN the actual main page run fine, but when i use codebehind and make another source file ( a .cs) to go with the aspx (as you would realistically) I get this : Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root...
13
3632
by: Siegfried Heintze | last post by:
I refered the engineer at my hosting service to http://support.microsoft.com/default.aspx?scid=kb;en-us;825738 where he tried to follow the directions there. He said there was no such file: Document settings\ServerName\ASPNET\Local settings\Temp I said it must be a typo, they meant to say c:\Documents And Settings\Server Name\ASPNET\Local settings\temp.
2
4178
by: Joseph Geretz | last post by:
Help me understand this, please. I have a Winforms app, lets call it WinApp.exe. I also have a DLL, lets call it WebBroker.dll. The purpose of WebBroker.dll is to broker an interface with a WebService. I don't encode this directly into MyWinApp, because I want to generate a single component which will be able to broker interface to the Web service for both .NET and VB6 apps. Naturally, I want WebBroker to use dynamic url reference....
6
3364
by: AppleBag | last post by:
I'm having the worst time trying to login to myspace through code. Can someone tell me how to do this? Please try it yourself before replying, only because I have asked this a couple of times in the past in other places, and while the help was much appreciated, it seemed everyone just wanted to 'theoretically' explain how to do it, but when I tried to do it myself, I couldn't login. I want to simply pass the email address and password to...
4
2217
by: Brad Isaacs | last post by:
I am working with ASP.NET 2.0 and using an SQL Server 2000 database. I am using Visual Studio 2005 and developing on my Local machine. I am working with Login controls ASP.Configuration, I wanted to move my work and needed to place it on the server. Using VS 2005 , went to BUILD -Publish Web Site Checked the box for :: Alow this precompiled site to be updatable.
7
1794
by: ksdh | last post by:
HI I am using the below script to create a file with 10000 iterations. What i want to do is, use a loop that would create a file with 1000 iterations for the 10000. So basically i would like to break up the file with 10000 iterations using a loop to have 10 files with 1000 iterations each. It might be easy to implement, but i am still new to perl. Any help is appreciated. use strict; # These are the configurations that you requested my...
12
2479
by: =?Utf-8?B?ZGdvdw==?= | last post by:
I designed a "contact_us" page in visual web developer 2005 express along with EW2 after viewing tutorials on asp.net's help page. Features work like they should, but I cannot figure out how to send contact info to email or data base when the "send" button is pressed. I've watched the tutorials over & over again. I just can't get it. Link: http://www.syfloristonline.zipa.com/contact_us.aspx. Need help
5
4960
by: jrod11 | last post by:
hi, I found a jquery html table sorting code i have implemented. I am trying to figure out how to edit how many colums there are, but every time i remove code that I think controls how many colums there are, it crashes. There are currently 6 columns, and I only want 4. How do I remove the last two (discount and date)? Here is a link: http://www.jaredmoore.com/tablesorter/docs/salestable.html Here is some jquery js that I think...
0
9687
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9543
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10257
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7567
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6808
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5467
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4144
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3761
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2941
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.