Tsinghua University Press, "Advanced Programming-C # Programming Applications", 1 January 2003, Benny Johansen & Matthew Reynolds, etc. Small problems, two of which are similar to nature issues 1: streamreader streamreader = new streamreader (filestream); garbled when the open file is Chinese characters. When the file is opened, the read file content is converted to a StreamReader type, which is used by the .NET platform default encoding method, resulting in inconsistencies when the encoding type is inconsistent, and the last data will of course be garbled. The original sentence read StreamReader streamReader = new StreamReader (fileStream, Encoding.Default); we can solve the problem with this sentence Encoding.Default, expressed in text file encoding type encoding any original question two: private void menuFileSave_Click (object sender, System .EventArgs e) {SaveFileWithName (m_FileName);}! private void SaveFileWithName (string filePath) {if (filePath = null) {SaveFile (filePath); m_FileName = filePath; SetModified (false);} else
{SaveFileDialog1.Filter = "Text files (. * Txt) | * .txt | All files (* *.) | * *."; SaveFileDialog1.FilterIndex = 1; saveFileDialog1.RestoreDirectory = true; if (saveFileDialog1.ShowDialog () == DialogResult.ok) {Savefile (SaveFileDialog1.FileName); m_filename = SaveFileDialog1.FileName; setModified (false);}}} When the program is run, no text file is opened, after editing, if you choose Files - > "Save As" Do not have problems, when pressing "Save", prompt "Empty path name is illegal", because when "Save", promote the MenuFileSave_Click event, execute SaveFileWithname (m_filename) , But at this time, M_FileName is empty because there is no open file, so that the error resolved is simple, set a variable, determine whether to open the file private bool isopened; void setpened (BOOL M) {isopened = m;}