Small programs with many problems. Some are the focus of the program, some do not know the place, query information to solve. Write down the old brain. Mark.
1. How can I read good-end Chinese text with garbled characters? (Further exercises are required for reading and writing files .)
// The encoding format is different. The dual-byte storage causes garbled characters when reading a single byte.
// Add the encoding parameter.
Streamreader sr = new streamreader (listbox1.items [I]. tostring (), system. Text. encoding. getencoding ("gb2312 "));
// Create a new Unicode text file. You only need to add the encoding parameter.
Streamwriter Sw = new streamwriter ("E:/" + textbox1.text + file + ". txt", true, system. Text. encoding. Unicode );
2. How to read files in batches?
// Set the multiselect attribute of openfiledialog to true.
// Reference the openfiledialog Method
Openfiledialog openfiledialog1 = new openfiledialog ();
Openfiledialog1.multiselect = true; // multi-file reference
If (openfiledialog1.showdialog () = dialogresult. OK)
...{
Arraylist list = new arraylist ();
// All file paths exist in filenames.
Foreach (string STR in openfiledialog1.filenames)
...{
List. Add (STR );
}
}
3. Why is the Chinese Input Method invalid?
// Set the input method, which is imemode in C.
// Generally, the default imemode value is no control. Basically, the control has the imemode attribute,
// To control the Input Method for a single control, change the imemode attribute of the control to on.
// To support the entire form, change the imemode attribute of form to on