如何将颜色对话框的输出保存到 ini 文件中?

How can I save the output of a color Dialog into a ini-file?

我目前正在编写我的第一个应用程序。我将用户配置保存到一个 ini 文件中。现在我需要保存一个颜色代码,它是程序从 colorDialog 中获取的。

代码部分如下:

public void button1_Click(object sender, EventArgs e)
{
    ColorDialog colorDialog1 = new ColorDialog();
    colorDialog1.ShowDialog();
    if (colorDialog1.ShowDialog() == DialogResult.OK)
    {
        string input = null;
        var userprofile_location = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + @"\Appdata\Roaming\GameCentral";
        var settings = new IniFile(userprofile_location + @"\settings.ini");
        //IniFile.Write;
        settings.Write("1", input, "Color");
    }
}

如下设置输入并将输入写入ini文件。它应该保存十六进制代码。

string input = (colorDialog1.Color.ToArgb() & 0x00FFFFFF).ToString("X6")

如果你想使用反向十六进制代码,请这样做:

string code = "FFDDAA";

Color color = Color.FromArgb(Convert.ToInt32(code, 16));