softairhk

softairhk

  • NA
  • 115
  • 0

File Write Problem

Oct 14 2003 12:35 PM
Hello! What's wrong for my listed coding? I can create a file with the inputted file name, but how can I add sContent into my created file? Please give me reply asap. Thanks! //Save File private void btnSave_Click(object sender, System.EventArgs e) { string sCheck=txtFileName.Text; if(sCheck.Length !=0) { string strLog=txtFileName.Text; FileStream fw = new FileStream(strLog +"." + "dat" ,FileMode.CreateNew, FileAccess.Write); string sContent="How to add this message into the created file"; fw.Write(sContent); fw.Close(); MessageBox.Show("File Created and Written successfully!","Finished",MessageBoxButtons.OK,MessageBoxIcon.Information); } else { MessageBox.Show("File Name is empty, cannot save file!","Error",MessageBoxButtons.OK,MessageBoxIcon.Error); } }

Answers (5)