技术开发 频道

用程序读取打开的关联文件


【IT168技术文档】

  示例在Form中有一个 Richtextbox
this.richTextBox1.Location = new System.Drawing.Point(21, 28); this.richTextBox1.Name = "richTextBox1"; this.richTextBox1.Size = new System.Drawing.Size(233, 168); this.richTextBox1.TabIndex = 0; this.richTextBox1.Text = "";
  应用程序入口处:
static void Main(String []args) { String filePath = null; if (args.Length != 0) { filePath = args[0]; } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1(filePath)); }
  继承 Forms 的类
public partial class Form1 : Form { String fp = null; public Form1(String filePath) { fp = filePath; InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { if (fp != null) { richTextBox1.LoadFile(fp, RichTextBoxStreamType.PlainText); } } }
  结束。
  一直在努力,致力于计算机局域网研究和工具开发
0
相关文章