Thư viện tri thức trực tuyến
Kho tài liệu với 50,000+ tài liệu học thuật
© 2023 Siêu thị PDF - Kho tài liệu học thuật hàng đầu Việt Nam

Tài liệu đang bị lỗi
File tài liệu này hiện đang bị hỏng, chúng tôi đang cố gắng khắc phục.
Tài liệu File , Thư mục và IO phần cuối doc
Nội dung xem thử
Mô tả chi tiết
using System;
using System.Drawing;
using System.Windows.Forms;
public class SimpleEditForm : System.Windows.Forms.Form {
private System.Windows.Forms.MenuItem mnuFile;
private System.Windows.Forms.MenuItem mnuOpen;
private System.Windows.Forms.MenuItem mnuSave;
private System.Windows.Forms.MenuItem mnuExit;
private System.Windows.Forms.RichTextBox rtDoc;
// (Bỏ qua phần mã designer.)
private void mnuOpen_Click(object sender, System.EventArgs e) {
OpenFileDialog dlg = new OpenFileDialog();
dlg.Filter = "Rich Text Files (*.rtf)|*.RTF|" +
"All files (*.*)|*.*";
dlg.CheckFileExists = true;
dlg.InitialDirectory = Application.StartupPath;
if (dlg.ShowDialog() == DialogResult.OK) {
rtDoc.LoadFile(dlg.FileName);
rtDoc.Enabled = true;
}
}
private void mnuSave_Click(object sender, System.EventArgs e) {
SaveFileDialog dlg = new SaveFileDialog();
dlg.Filter = "RichText Files (*.rtf)|*.RTF|Text Files (*.txt)|*.TXT" +
"|All files (*.*)|*.*";
dlg.CheckFileExists = true;
dlg.InitialDirectory = Application.StartupPath;
if (dlg.ShowDialog() == DialogResult.OK) {
rtDoc.SaveFile(dlg.FileName);
}