How can i set the code when i checked the checkbox, it should be ask the Opendialogbox to open a file?


  • C#:
    In my application program, i set a checkbox to ask an openfiledialogbox to choose a file when the checkbox is checked or else it doesn't ask the openfiledialogbox.  When i choose a file through openfiledialogbox, that file's name along with path should be save in some text file. At the same, the status of the checkbox also should be save into that file using some delimiter symbol.

         When i run the application program, it should check the status of the checkbox from the previous saved file. if the status is checked, then it should ask openfiledialogbox to change the file.

    [For Example, it's like asking a Nero's savedialog messagebox when after the burn process completed]
    Thursday, August 20, 2009 1:38 AM


  • Hi,
    I hope it will help you..
     private void checkBox1_CheckedChanged(object sender, EventArgs e)
    if (checkBox1.Checked.Equals(true))
    OpenFileDialog diag = new OpenFileDialog();
    string fileSelected = diag.FileName.ToString()+"~"+checkBox1.Checked;
    using( StreamWriter wrtr = new StreamWriter(@"c:\\files.txt"))
    private void btnRead_Click(object sender, EventArgs e)
    StreamReader sr = new StreamReader(@"c:\\files.txt");
    string line = sr.ReadLine();
    if (!String.IsNullOrEmpty(line))
    String[] findCheck = line.Split('~');
    if (Convert.ToBoolean(findCheck[1].ToString()))
    	DialogResult dr = new DialogResult();                  
    	dr=MessageBox.Show("Do You Want To Launch The File", "Message", MessageBoxButtons.OKCancel);
    	   //do something

    Best Regards, C.Gnanadurai ----------------------- Please mark the post as answer if it is helpfull to you
    • Proposed as answer by Harry Zhu Tuesday, August 25, 2009 6:13 AM
    • Marked as answer by Harry Zhu Thursday, August 27, 2009 1:12 AM
    Thursday, August 20, 2009 8:34 AM