http://blog.csdn.net/lanman/article/details/5287717

解决方案 »

  1.   

    可以把窗体类,序列化了,存成xml
      

  2.   

    写个ini配置文件如何?//类
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;namespace F6
    {
        class INI
        {
            //声明INI文件的写操作函数 WritePrivateProfileString()
            [System.Runtime.InteropServices.DllImport("kernel32")]
            private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);
            // 声明INI文件的读操作函数 GetPrivateProfileString()
            [System.Runtime.InteropServices.DllImport("kernel32")]
            private static extern int GetPrivateProfileString(string section, string key, string def, System.Text.StringBuilder retVal, int size, string filePath);
            private string sPath = null;
            public INI(string path)
            {
                this.sPath = path;
            }
            public void Writue(string section, string key, string value)
            {
                // section=配置节,key=键名,value=键值,path=路径
                WritePrivateProfileString(section, key, value, sPath);
            }
            public string ReadValue(string section, string key)
            {
                // 每次从ini中读取多少字节
                System.Text.StringBuilder temp = new System.Text.StringBuilder(255);
                // section=配置节,key=键名,temp=上面,path=路径
                GetPrivateProfileString(section, key, "", temp, 255, sPath);
                return temp.ToString();
            }
        }
    }
    //ini文件格式
    [Database]
    server=
    database=
    username=
    password=                Current = Directory.GetCurrentDirectory();
                    INI ini = new INI(Current + "/database.ini");
                    ini.Writue("Database", "server", "");
                    ini.Writue("Database", "database", "");
                    ini.Writue("Database", "username", "");
                    ini.Writue("Database", "password", "");
                    ini.Writue("Database", "server", "" + server + "");
                    ini.Writue("Database", "database", "" + database + "");
                    ini.Writue("Database", "username", "" + username + "");
                    ini.Writue("Database", "password", "" + password + "");
      

  3.   

    写在ini里比较好 也比较传统
      

  4.   

    ini或者xml都可以,更支持使用xml
      

  5.   

    为什么不用app.config?WinForm中每个控件都有一个ApplicationSetting属性。你可以将控件属性保存到app.config中。
      

  6.   

    没啥要求的话用settings就好了
      

  7.   

    右键单击项目-弹出菜单选属性,然后选Settings,
    这里可以手动添加程序配置信息,按下F7,进入代码模式.
    它是一个静态类,允许你的程序在运行时动态读取和保存
    配置信息,它所对应的文件是在所在项目的Properties
    文件夹下生成的一个Settings.settings类,
    就用这个吧,自带的省事又省心,多好,微软造的玩意不是吃干饭的.