private void Save_Click(object sender, EventArgs e)//create a directory with a new patient and all the //possible related information { string newDirectory = ""; if (thisP != null) // if you are simply going to modify this patient { newDirectory = thisP.getPath(); } else // if this patient is new { newDirectory = "ROOT\\" + nextFreePatient(); } Directory.CreateDirectory(newDirectory); string toInsert = "cd = 12345 ;name = " + nameText.Text.Trim() + "; surname = " + surnameText.Text.Trim() + "; date = " + dateText.Text.Trim() + "; sex = " + sexText.Text.Trim() + "; notes = " + notesText.Text.Trim(); int options = this.optionalsGrid.RowCount; for (int i = 0; i < options; i++) { toInsert += "; " + this.optionalsGrid.Rows[i].Cells[0].Value + " = "; toInsert += this.optionalsGrid.Rows[i].Cells[1].Value; } textParser tp = new textParser(newDirectory + "\\info.txt", "first passphrase test"); tp.Write(toInsert); this.Refresh(); }