C # Some problems caused by config.exe,

Source: Internet
Author: User

C # Some problems caused by config.exe,

1 public static void CreateConfig () {2 // c # You can add a built-in app. config. We can use the ConfigrationManager class to operate related nodes easily. The operation method is not described here, 4 // problems caused when the program is compiled, a file in the format of program name .config.exe is automatically generated. 5 // This is the configuration file saved in our actual operation, if this file is lost, we need to determine whether the 6 // configuration file exists. That is to say, this configuration only generates 7 8 9 at compilation. // solution 10 // set the app. config is set to the embedded resource type, get the resource file stream through Assembly 11 // re-write the configuration to the root directory 12 Assembly ass = Assembly. getExecutingAssembly (); 13 // The path can also be through AppDomain. currentDomain. setupInformation. configurationFile obtains the configuration path 14 using (Stream s = ass. getManifestResourceStream (ass. getName (). name + ". app. config ") {15 byte [] buf = new byte [(int) s. length]; 16 s. read (buf, 0, buf. length); 17 File. writeAllBytes (cfPath, buf); 18} 19}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.