473,385 Members | 1,919 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,385 software developers and data experts.

C# Console App Deleting my config file - HELP!

I have a simple C# console app that needs to read the appname.exe.config
file to get db connect strings etc. from the <appSettings>. When the app
starts, it deletes the file! I can't figure it out. When I set a break point
on the first line in MAIN and check for the file, it is gone!

This is a 4 hour app, but I have spent all day trying to understand why the
config file is being deleted. Any help would be greatly appreciated.

Thanks very much in advance,

Richard Kessler
Jul 21 '05 #1
3 4279
Hello Richard,

Thanks for your post. As I understand, the proboem you are facing is that
your application configuration file will be deleted automatically. To
narrow down the problem, I think more information is needed:

1. Where does the config file reside? Did you add it to your project?

2. Does the problem occur to a specific project or to all the projects? I
recommend you perform the following steps to check it:
a. Create a new C# console application.
b. Select the menu "Project" -> "Add New Item...".
c. Double-click the "Application configuration file" to add a config file.
d. Run the application and see if it will be deleted.

3. It seems to me that file is gone before starting your console
application, I believe that it may be deleted by other process say, VS .NET
IDE. Please use FileMon to find out which process deletes the config file.
You can download FileMon utility at
http://www.sysinternals.com/ntw2k/source/filemon.shtml.

I look forward to your response.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #2
>I have a simple C# console app that needs to read the appname.exe.config
file to get db connect strings etc. from the <appSettings>. When the app
starts, it deletes the file! I can't figure it out. When I set a break point
on the first line in MAIN and check for the file, it is gone!


Yes, the IDE will wipe out the target directory when compiling.

The solution is to add your config file to your project, and make sure
to call it "app.config" (exactly that - DO NOT call it anything else,
DO NOT expand "app" to be your app's name, or anything like that!).

In this case, the VS.NET IDE will always but your app.config file,
renamed to <yourproject.exe.config>, into your output directory.

Marc
================================================== ==============
Marc Scheuner May The Source Be With You!
Bern, Switzerland m.scheuner(at)inova.ch
Jul 21 '05 #3
Hi,

Where do you have the file "appname.exe.config"?? in the Bin folder??
I had the same problem with a config file in the bin folder. when th
eproject is compiled it deletes all the bin folder content.

"Richard" <ri************@matteicos.com> escreveu na mensagem
news:OW**************@TK2MSFTNGP10.phx.gbl...
I have a simple C# console app that needs to read the appname.exe.config
file to get db connect strings etc. from the <appSettings>. When the app
starts, it deletes the file! I can't figure it out. When I set a break point on the first line in MAIN and check for the file, it is gone!

This is a 4 hour app, but I have spent all day trying to understand why the config file is being deleted. Any help would be greatly appreciated.

Thanks very much in advance,

Richard Kessler

Jul 21 '05 #4

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

Similar topics

3
by: Kyle Blaney | last post by:
Suppose myApp.exe.config contains a redirection from version 1.0 of someAssembly to version 1.1 of someAssembly. When a user deletes myApp.exe.config and version 1.0 of someAssembly is installed...
3
by: Richard | last post by:
I have a simple C# console app that needs to read the appname.exe.config file to get db connect strings etc. from the <appSettings>. When the app starts, it deletes the file! I can't figure it...
6
by: yaron | last post by:
Hi all, I want to give a sample console application for the user with 2 configuration files. I want to give also a 2 .bat files for running the sample application, one for each configuration...
2
by: Vikram | last post by:
I am using log4net in a vb.net console application. But its not working. I have added congif setting in app.config file also No error is generated but app. does not write to log file. ...
2
by: Jim Heavey | last post by:
Hello, I used VS 2005 to create a console application. Got the application working just fine. I then decided I would create a folder for each of my "console" applications within that project. I...
1
by: John Wright | last post by:
I am running a console application that connects to an Access database (8 million rows) and converts it to a text file and then cleans and compacts the database. When it runs I get the following...
6
by: keeps21 | last post by:
I'm having a bit of trouble creating a page to delete a story from the content table in my database. I have checked my DELETE query directly in phpmyadmin and it is working fine. I am echoing...
0
by: Reg | last post by:
Hello All! I have a small Console based Application which acts like Http server. HttpListener is used for Http requests and responses. Now I would like to use Digest Authentication and I made...
1
by: mquincey | last post by:
One of the features offered by .NET 2.0 is the use of the TraceSource class. In an attempt to demonstrate its use, I wanted to run my test under the following conditions: 1. Use TraceSource class...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
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.