How to Add a Configuration File to your Windows Forms application Kā pievienot konfigurācijas fails Windows Forms pieteikumu
When you are creating a new Windows Forms application, it isn't immediately obvious how to get a configuration file for your application. Kad veidojat jaunu Windows Forms pieteikumu, tas nav uzreiz skaidrs, kā iegūt konfigurācijas failā jūsu pieteikumu. 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. Jūsu pieteikums konfigurācijas fails ir paredzēts saukt executablename.exe.config, un jābūt tajā pašā direktorijā, kā savu pieteikumu, lai. NET Framework automātiski izmantot.
But when you create the configuration file in the \bin\debug directory, it gets overwritten immediately when you do a new build. Bet kad tu izveidot konfigurācijas failu \ bin \ Debug directory, tā izpaužas pārrakstīti uzreiz, kad tu jaunu objektu būvniecību. That's slightly annoying. Tas ir nedaudz kaitinošas.
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. Pareizā veidā pievienot šo failu pievienot jaunus jaunas konfigurācijas failu ar nosaukumu App.config savam projektam, kas Visual Studio automātiski kopēt un pārdēvēt to pašu nosaukumu, kā Jūsu izpildāmā vārdu, kad jūs būvēt.
There's a really simple way to do this.. Tur ir tiešām vienkāršs veids, kā to .. simply go to the File \ Add New Item menu, or hit Ctrl+Shift+A vienkārši doties uz File \ Add New Item izvēlni, vai nospiediet Ctrl + Shift + 
You'll notice that it's already set to App.config for you. Jūs ievērosiet, ka tas jau ir App.config jums. Just hit the Open button. Just hit pogas Atvērt.
If you look in the Solution Explorer, you will see that the config file is in your project: Ja jūs Skatīt Solution Explorer, jūs redzēsiet, ka konfig fails ir jūsu projektā:

Now build your application, and take a look in the \bin\debug\ folder. Tagad veidot savu pieteikumu un veikt skatās \ bin \ Debug \ mapē. You'll see that the configuration file has automatically been generated and named correctly for your executable: Jūs redzēsit, ka konfigurācijas fails ir automātiski tiek iegūta un nosauc pareizi jūsu izpildāmā:

If you change the name of the outputted file, Visual Studio is smart enough to generate the new filename correctly. Ja maināt nosaukumu outputted fails, Visual Studio ir pietiekami gudrs, lai radītu jaunu faila nosaukumu pareizi.
Enjoy Configuring! Enjoy konfigurēšana!

Daily Email Updates Daily Email Updates
You can get our how-to articles in your inbox each day for free. Jūs varat saņemt mūsu how-to rakstus savā pastkastītē katru dienu par brīvu. Just enter your name and email below: Vienkārši ievadiet jūsu vārdu un e-pasta zemāk:



thank you very much really helpful , thanks a lot thank you very much patiešām noderīga, pateicoties daudz