app.config文件的读写

来源:互联网 发布:node path resolve 编辑:程序博客网 时间:2024/04/19 16:15

下图为读取代码

  #region 返回监控文件夹的路径
        public String MoiDir()
        {
            String path = "";
            ExeConfigurationFileMap file = new ExeConfigurationFileMap();
            file.ExeConfigFilename = System.Windows.Forms.Application.ExecutablePath + ".config";
            Configuration config = System.Configuration.ConfigurationManager.OpenMappedExeConfiguration(file, ConfigurationUserLevel.None);
            var myApp = (AppSettingsSection)config.GetSection("appSettings");
            path = myApp.Settings["FilepPath"].Value;
            return path;
        }
        #endregion


赋值代码只需要给myApp.Settings["FilepPath"].Value 赋值即可
0 0