private void OpenFile() { try { openFileDialog1.Filter = "XML Files (*.xml)|*.xml|Text Files (*.txt)|*.txt|All Files (*.*)|*.*"; openFileDialog1.FilterIndex = 1; openFileDialog1.Title = "Select a file to open"; openFileDialog1.FileName = ""; openFileDialog1.ShowDialog(); if (openFileDialog1.FileName != "") { xmlFileName = openFileDialog1.FileName; txtXmlFile.Text = xmlFileName.Trim(); RichTextBox1.LoadFile(openFileDialog1.FileName, RichTextBoxStreamType.PlainText); this.Text = "Xml Editor | " + xmlFileName.Substring(xmlFileName.LastIndexOf("\\") + 1); } Changed = false; } catch (Exception ex) { PepsiLiteErrorHandling.WriteErrorLog(ex.ToString()); } }
public PopupHelpForm() { InitializeComponent(); //現在のコードを実行しているAssemblyを取得 Assembly myAssembly = Assembly.GetExecutingAssembly(); //指定されたマニフェストリソースを読み込む string[] names = myAssembly.GetManifestResourceNames(); Stream stream = myAssembly.GetManifestResourceStream("MyScrapBook.help.rtf"); RichTextBox1.LoadFile(stream, RichTextBoxStreamType.RichText); }