Important! This is an automatic machine translated page. If you can read english, you should Click Here to read the original English version of the article.

How to Add a Configuration File to your Windows Forms application Lägga till en konfigurationsfil för att din Windows Forms ansökan

When you are creating a new Windows Forms application, it isn't immediately obvious how to get a configuration file for your application. När du skapar ett nytt Windows Forms ansökan, är det inte direkt uppenbart hur man får en konfigurationsfil för din ansökan. Your application configuration file is supposed to be called executablename.exe.config, and should be in the same directory as your application in order for the .NET framework to automatically use it. Din ansökan konfigurationsfilen är tänkt att kallas executablename.exe.config, och bör vara i samma mapp som din ansökan för att. NET Framework för att automatiskt använda den.

But when you create the configuration file in the \bin\debug directory, it gets overwritten immediately when you do a new build. Men när du skapar konfigurationsfilen i \ bin \ debug katalogen, blir det skrivs över direkt när du gör en ny byggnad. That's slightly annoying. Det är något irriterande.

The proper way to add this file is to add new new configuration file called App.config to your project, which Visual Studio will automatically copy and rename to the same name as your executable's name when you do a build. Det korrekta sättet att lägga till den här filen är att lägga till ny ny konfigurationsfil kallad App.config till ditt projekt, som Visual Studio kommer automatiskt kopiera och byta namn till samma namn som ditt körbara namn när du gör en build.

There's a really simple way to do this.. Det finns ett riktigt enkelt sätt att göra detta .. simply go to the File \ Add New Item menu, or hit Ctrl+Shift+A helt enkelt gå till Arkiv \ Lägg till nytt objekt menyn, eller tryck Ctrl + Skift + A

You'll notice that it's already set to App.config for you. Du kommer att märka att det redan är inställd på App.config för dig. Just hit the Open button. Bara trycka på knappen Öppna.

If you look in the Solution Explorer, you will see that the config file is in your project: Om du tittar i Solution Explorer kommer du se att config filen i projektet:


Now build your application, and take a look in the \bin\debug\ folder. Nu bygga din ansökan och ta en titt i \ bin \ debug \ broschyren. You'll see that the configuration file has automatically been generated and named correctly for your executable: Du ser att konfigurationsfilen automatiskt har genererats och rätt namn för din körbar:

If you change the name of the outputted file, Visual Studio is smart enough to generate the new filename correctly. Om du ändrar namnet på outputted filen är Visual Studio smart nog för att generera nya filnamnet korrekt.

Enjoy Configuring! Enjoy Konfigurera!

This article was originally written on 10/17/06 Tagged with: Denna artikel skrevs ursprungligen på 10/17/06 Märkta med: Programming Programmering

Daily Email Updates Dagligt Updates

You can get our how-to articles in your inbox each day for free. Du kan få våra instruktioner artiklar i din inkorg varje dag gratis. Just enter your name and email below: Skriv bara in ditt namn och e-postadress nedan:


Name: Namn:
Email: Email:

Comments (1) Kommentarer (1)

  1. renuka Renuka

    thank you very much really helpful , thanks a lot Tack så mycket verkligen hjälpsam, tack själv en lott


Leave a Comment Lämna en kommentar




Leave your Lämna ditt friendly friendly comment here. kommentar här.

If you have a computer help question, Om du har en dator hjälp fråga, click here to leave it on the forums Klicka här för att lämna det i forumen instead. istället.

Note: Your comment may not show up immediately on the site. Obs: Din kommentar inte får visa upp omedelbart på platsen.

Our Friends Our Friends
Getting Started Komma igång


About How-To Geek Om How-To Geek
What Is That Process? Hur skall den processen?
svchost.exe svchost.exe
jusched.exe SynTPEnh.exe
dwm.exe dwm.exe
ctfmon.exe CTFMON.EXE
wmpnetwk.exe wmpnetwk.exe
wmpnscfg.exe wmpnscfg.exe
rundll32.exe rundll32.exe
wfcrun32.exe wfcrun32.exe
Ipoint.exe Ipoint.exe
Itype.exe Itype.exe
Wfica32.exe Wfica32.exe
Mobsync.exe Mobsync.exe
conhost.exe conhost.exe
Dpupdchk.exe Dpupdchk.exe Adobe_Updater.exe Adobe_Updater.exe

Copyright © 2006-2009 HowToGeek.com. Copyright © 2006-2009 HowToGeek.com. All Rights Reserved. All Rights Reserved.