473,387 Members | 1,611 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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\\FundExplorer\\
Index\\Copy of IntlIndex");
---------------------------------------------------------------------

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

<configuration>

<appSettings>

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

<!-- Example: <add key="settingName" value="settingValue"/> -->

<add key="reportingService.ServerName" value="Http://Localhost" />
<!-- No ending "/" -->

<add key="connOperations.ConnectionString" value="Integrated
Security=SSPI;Persist Security Info=False;Data Source=HIRST-IT1\
TEST;Initial Catalog=FundManager42205;" />

</appSettings>

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

System.Configuration.AppSettingsReader appReader =

new System.Configuration.AppSettingsReader()
;

string connString = (string)appReader.GetValue(

"connOperations.ConnectionString",typeof
(string));

SqlConnection conn = new SqlConnection(connString);
------------------------------------------------------------------------

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\\FundExplorer\\
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= "workstation id=HIRST-IT1;packet size=4096;"+

"Integrated Security=SSPI;initial catalog=FundManager42205;"+ "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\\FundExplorer\\
Index\\Copy of IntlIndex\\"+fri.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 15808
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.com" <fo***@nospam.DotNetMonster.com> wrote in
message news:1b******************************@DotNetMonste r.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\\FundExplorer\\
Index\\Copy of IntlIndex");
---------------------------------------------------------------------

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

<configuration>

<appSettings>

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

<!-- Example: <add key="settingName" value="settingValue"/> -->

<add key="reportingService.ServerName" value="Http://Localhost" />
<!-- No ending "/" -->

<add key="connOperations.ConnectionString" value="Integrated
Security=SSPI;Persist Security Info=False;Data Source=HIRST-IT1\
TEST;Initial Catalog=FundManager42205;" />

</appSettings>

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

System.Configuration.AppSettingsReader appReader =

new
System.Configuration.AppSettingsReader()
;

string connString = (string)appReader.GetValue(

"connOperations.ConnectionString",typeof
(string));

SqlConnection conn = new SqlConnection(connString);
------------------------------------------------------------------------

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\\FundExplorer\\
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= "workstation id=HIRST-IT1;packet size=4096;"+

"Integrated Security=SSPI;initial catalog=FundManager42205;"+ "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\\FundExplorer\\
Index\\Copy of IntlIndex\\"+fri.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\\FundExplorer\\
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
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....
25
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...
13
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:...
2
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...
6
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...
4
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...
7
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...
12
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...
5
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.