当前位置: 首页>>代码示例>>C#>>正文


C# Configuration.SaveAs方法代码示例

本文整理汇总了C#中System.Configuration.Configuration.SaveAs方法的典型用法代码示例。如果您正苦于以下问题:C# Configuration.SaveAs方法的具体用法?C# Configuration.SaveAs怎么用?C# Configuration.SaveAs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Configuration.Configuration的用法示例。


在下文中一共展示了Configuration.SaveAs方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OptionsForm

        private OptionsForm(bool local)
        {
            InitializeComponent();
            
            // Copy the Bootstrap.exe file to New.exe,
            // so that the configuration file will load properly
            string currentDir = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
            string sandboxDir = Path.Combine(currentDir, "Sandbox");

            if (!File.Exists(Path.Combine(sandboxDir, "New.exe")))
            {
                File.Copy(
                    Path.Combine(sandboxDir, "Bootstrap.exe"),
                    Path.Combine(sandboxDir, "New.exe")
                );
            }

            string filename = local ? "New.exe" : "Bootstrap.exe";
            string filepath = Path.Combine(sandboxDir, filename);
            _Configuration = ConfigurationManager.OpenExeConfiguration(filepath);
            
            // Get the DDay.Update configuration section
            _Cfg = _Configuration.GetSection("DDay.Update") as DDayUpdateConfigurationSection;

            // Set the default setting on which application folder to use.
            cbAppFolder.SelectedIndex = 0;

            SetValuesFromConfig();

            if (!local)
                _Configuration.SaveAs(Path.Combine(sandboxDir, "New.exe.config"));
        }
开发者ID:jltrem,项目名称:DDay.Update,代码行数:32,代码来源:OptionsForm.cs

示例2: ReadToolsetConfigurationSection

        internal static ToolsetConfigurationSection ReadToolsetConfigurationSection(Configuration configuration)
        {
            ToolsetConfigurationSection configurationSection = null;

            // This will be null if the application config file does not have the following section 
            // definition for the msbuildToolsets section as the first child element.
            //   <configSections>
            //     <section name=""msbuildToolsets"" type=""Microsoft.Build.Evaluation.ToolsetConfigurationSection, Microsoft.Build"" />
            //   </configSections>";
            // Note that the application config file may or may not contain an msbuildToolsets element.
            // For example:
            // If section definition is present and section is not present, this value is not null
            // If section definition is not present and section is also not present, this value is null
            // If the section definition is not present and section is present, then this value is null
            if (null != configuration)
            {
                ConfigurationSection msbuildSection = configuration.GetSection("msbuildToolsets");
                configurationSection = msbuildSection as ToolsetConfigurationSection;

                if (configurationSection == null && msbuildSection != null) // we found msbuildToolsets but the wrong type of handler
                {
                    if (String.IsNullOrEmpty(msbuildSection.SectionInformation.Type) ||
                        msbuildSection.SectionInformation.Type.IndexOf("Microsoft.Build", StringComparison.OrdinalIgnoreCase) >= 0)
                    {
                        // Set the configuration type handler to the current ToolsetConfigurationSection type
                        msbuildSection.SectionInformation.Type = typeof(ToolsetConfigurationSection).AssemblyQualifiedName;

                        try
                        {
                            // fabricate a temporary config file with the correct section handler type in it
                            string tempFileName = FileUtilities.GetTemporaryFile();

                            // Save the modified config
                            configuration.SaveAs(tempFileName + ".config");

                            // Open the configuration again, the new type for the section handler will do its stuff
                            // Note that the OpenExeConfiguraion call uses the config filename *without* the .config
                            // extension
                            configuration = ConfigurationManager.OpenExeConfiguration(tempFileName);

                            // Get the toolset information from the section using our real handler
                            configurationSection = configuration.GetSection("msbuildToolsets") as ToolsetConfigurationSection;

                            File.Delete(tempFileName + ".config");
                            File.Delete(tempFileName);
                        }
                        catch (Exception ex)
                        {
                            if (ExceptionHandling.NotExpectedException(ex))
                            {
                                throw;
                            }
                        }
                    }
                }
            }

            return configurationSection;
        }
开发者ID:JamesLinus,项目名称:msbuild,代码行数:59,代码来源:ToolsetElement.cs

示例3: CoreSettings


//.........这里部分代码省略.........
                    needtowrite = true;
                }
                key = delegate(String StringToMatch) { return StringToMatch == "SubFoldersForCollections"; };
                if (!Array.Exists<String>(keys, key))
                {
                    m_Configuration.AppSettings.Settings.Add("SubFoldersForCollections", "True");
                    needtowrite = true;
                }
                key = delegate(String StringToMatch) { return StringToMatch == "SynchronizeWebCaches"; };
                if (!Array.Exists<String>(keys, key))
                {
                    m_Configuration.AppSettings.Settings.Add("SynchronizeWebCaches", "True");
                    needtowrite = true;
                }
                key = delegate(String StringToMatch) { return StringToMatch == "TemporaryDirectory"; };
                if (!Array.Exists<String>(keys, key))
                {
                    m_Configuration.AppSettings.Settings.Add("TemporaryDirectory", "temp");
                    needtowrite = true;
                }
                key = delegate(String StringToMatch) { return StringToMatch == "UICulture"; };
                if (!Array.Exists<String>(keys, key))
                {
                    m_Configuration.AppSettings.Settings.Add("UICulture", "en");
                    needtowrite = true;
                }
                key = delegate(String StringToMatch) { return StringToMatch == "UploadCapacity"; };
                if (!Array.Exists<String>(keys, key))
                {
                    m_Configuration.AppSettings.Settings.Add("UploadCapacity", "16384");
                    needtowrite = true;
                }
                key = delegate(String StringToMatch) { return StringToMatch == "UploadLimit"; };
                if (!Array.Exists<String>(keys, key))
                {
                    m_Configuration.AppSettings.Settings.Add("UploadLimit", "8192");
                    needtowrite = true;
                }
                key = delegate(String StringToMatch) { return StringToMatch == "UseBytesInsteadOfBits"; };
                if (!Array.Exists<String>(keys, key))
                {
                    m_Configuration.AppSettings.Settings.Add("UseBytesInsteadOfBits", "False");
                    needtowrite = true;
                }
                key = delegate(String StringToMatch) { return StringToMatch == "UserWasAsked"; };
                if (!Array.Exists<String>(keys, key))
                {
                    m_Configuration.AppSettings.Settings.Add("UserWasAsked", "False");
                    needtowrite = true;
                }
                key = delegate(String StringToMatch) { return StringToMatch == "WriteLogfile"; };
                if (!Array.Exists<String>(keys, key))
                {
                    m_Configuration.AppSettings.Settings.Add("WriteLogfile", "True");
                    needtowrite = true;
                }

                if (needtowrite)
                    m_Configuration.Save();
            }
            else
            {
                m_Configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                m_Configuration.AppSettings.Settings.Add("ActivateOnlineSignature", "False");
                m_Configuration.AppSettings.Settings.Add("ActivateSearchDB", "False");
                m_Configuration.AppSettings.Settings.Add("AutoMoveDownloads", "False");
                m_Configuration.AppSettings.Settings.Add("AutoMoveDownloadsIntervall", "60");
                m_Configuration.AppSettings.Settings.Add("AverageConnectionsCount", "5");
                m_Configuration.AppSettings.Settings.Add("ConfigurationFile", "Config.xml");
                m_Configuration.AppSettings.Settings.Add("CorruptDirectory", "corrupt");
                m_Configuration.AppSettings.Settings.Add("DownloadCapacity", "131072");
                m_Configuration.AppSettings.Settings.Add("DownloadLimit", "65536");
                m_Configuration.AppSettings.Settings.Add("FirstStart", "False");
                m_Configuration.AppSettings.Settings.Add("HasDownloadLimit", "False");
                m_Configuration.AppSettings.Settings.Add("HasUploadLimit", "False");
                m_Configuration.AppSettings.Settings.Add("IncomingDirectory", "incoming");
                m_Configuration.AppSettings.Settings.Add("LogDirectory", "log");
                m_Configuration.AppSettings.Settings.Add("MaximumDownloadsCount", "5");
                m_Configuration.AppSettings.Settings.Add("MaxSearchDBResults", "1000");
                m_Configuration.AppSettings.Settings.Add("NewDownloadsToBeginngingOfQueue", "False");
                m_Configuration.AppSettings.Settings.Add("OnlineSignatureUpdateIntervall", "5");
                m_Configuration.AppSettings.Settings.Add("ParseCollections", "True");
                m_Configuration.AppSettings.Settings.Add("Port", "6097");
                m_Configuration.AppSettings.Settings.Add("PreferencesDirectory", "preferences");
                m_Configuration.AppSettings.Settings.Add("PreviewFiletypes", "wmv|mov|asf|avi|mpeg|mpg|mp3|flac|ogg|wav|wma");
                m_Configuration.AppSettings.Settings.Add("PreviewPlayer", "");
                m_Configuration.AppSettings.Settings.Add("PreviewParams", "");
                m_Configuration.AppSettings.Settings.Add("SearchDBCleanUpDays", "7");
                m_Configuration.AppSettings.Settings.Add("SubFoldersForCollections", "True");
                m_Configuration.AppSettings.Settings.Add("SynchronizeWebCaches", "True");
                m_Configuration.AppSettings.Settings.Add("TemporaryDirectory", "temp");
                m_Configuration.AppSettings.Settings.Add("UICulture", "en");
                m_Configuration.AppSettings.Settings.Add("UploadCapacity", "16384");
                m_Configuration.AppSettings.Settings.Add("UploadLimit", "8192");
                m_Configuration.AppSettings.Settings.Add("UseBytesInsteadOfBits", "False");
                m_Configuration.AppSettings.Settings.Add("UserWasAsked", "False");
                m_Configuration.AppSettings.Settings.Add("WriteLogfile", "True");
                m_Configuration.SaveAs(exeConfigurationFileMap.ExeConfigFilename);
            }
        }
开发者ID:Steeslice,项目名称:StealthNet-Alt,代码行数:101,代码来源:CoreSettings.cs


注:本文中的System.Configuration.Configuration.SaveAs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。