Problems encountered in text editor programming (to be continued)

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.