How to Add a Configuration File to your Windows Forms application Kuinka Lisää konfigurointitiedostoa Windows Lomakkeet
When you are creating a new Windows Forms application, it isn't immediately obvious how to get a configuration file for your application. Kun luot uuden Windows Lomakkeet, se ei ole välittömästi selvää, miten saada kokoonpano tiedoston hakemuksesi. 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. Hakemuksesi konfiguraatiotiedosto pitäisi olla nimeltään executablename.exe.config, ja pitäisi olla samassa hakemistossa kuin hakemuksen, jotta. NET Frameworkin automaattisesti käyttämään sitä.
But when you create the configuration file in the \bin\debug directory, it gets overwritten immediately when you do a new build. Mutta kun luot kokoonpano tiedosto \ bin \ debug-hakemistoon, se saa päälle heti, kun teet uuden rakentaa. That's slightly annoying. Se hieman harmittaa.
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. Oikea tapa lisätä tämän tiedoston lisätä uusia uuden kokoonpanon tiedoston nimeltä App.config projektiin, joka Visual Studio automaattisesti kopioida ja nimetä on sama nimi kuin oman suoritustiedoston nimi, kun teet rakentaa.
There's a really simple way to do this.. On olemassa todella yksinkertainen tapa tehdä tämä .. simply go to the File \ Add New Item menu, or hit Ctrl+Shift+A yksinkertaisesti mene File \ Add New Item-valikosta, tai paina Ctrl + Shift + 
You'll notice that it's already set to App.config for you. Huomaat, että se on jo asetettu App.config sinulle. Just hit the Open button. Painaa Avaa-painiketta.
If you look in the Solution Explorer, you will see that the config file is in your project: Jos et katso Solution Explorer, huomaatte, että config-tiedosto on projektissa:

Now build your application, and take a look in the \bin\debug\ folder. Nyt rakentaa oman hakemuksen ja ottaa katso \ bin \ debug \ kansio. You'll see that the configuration file has automatically been generated and named correctly for your executable: Huomaat, että asetustiedosto on automaattisesti luotu ja nimetty oikein sinun executable:

If you change the name of the outputted file, Visual Studio is smart enough to generate the new filename correctly. Jos muutat nimeä outputted tiedoston, Visual Studio on fiksu, että se synnyttää uutta tiedostonimeä oikein.
Enjoy Configuring! Nauti Configuring!

Daily Email Updates Päivittäinen päivitykset
You can get our how-to articles in your inbox each day for free. Voit saada myös ohjeartikkeleita postilaatikossa joka päivä ilmaiseksi. Just enter your name and email below: Anna nimesi ja sähköpostiosoitteesi alla:



thank you very much really helpful , thanks a lot Paljon kiitoksia todella hyödyllistä, kiitos paljon