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

I’m currently coding my first app. I am saving the Userconfiguration into an ini-file. Now I need to save a color code, which the program gets from a colorDialog.

Here’s the section of the code:

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");     } } 
Add Comment
1 Answer(s)

Set input as below and write input to ini file. it should save hexcode.

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

if you want to use back hexcode, do like this:

string code = "FFDDAA";  Color color = Color.FromArgb(Convert.ToInt32(code, 16)); 
Answered on July 16, 2020.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.