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}