PC Review


Reply
Thread Tools Rate Thread

C# Console App Deleting my config file - HELP!

 
 
Richard
Guest
Posts: n/a
 
      11th Feb 2004
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


 
Reply With Quote
 
 
 
 
Tian Min Huang
Guest
Posts: n/a
 
      12th Feb 2004
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.

 
Reply With Quote
 
Marc Scheuner [MVP ADSI]
Guest
Posts: n/a
 
      12th Feb 2004
>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
 
Reply With Quote
 
Pedro Joel Ferreira
Guest
Posts: n/a
 
      12th Feb 2004
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" <(E-Mail Removed)> escreveu na mensagem
news:(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
HttpListerner in Console App and Web Config Reg Microsoft ASP .NET 0 10th Sep 2007 05:55 PM
How to read web.config from console application bibhuti.nilesh@gmail.com Microsoft C# .NET 2 5th Jan 2007 11:06 AM
I am getting "Windows XP could not start because the following file is missing or corrupt: \WINDOWS\SYSTEM32\CONFIG\SYSTEM ", and I can't use the Recovery Console!! Alvin Windows XP General 3 23rd Nov 2004 04:06 AM
Access Web.Config from a Console / Windows application christopher green Microsoft C# .NET 4 23rd Jun 2004 03:27 PM
Deleting app.config file Kyle Blaney Microsoft Dot NET 3 22nd Oct 2003 09:28 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:29 AM.