C#怎么用代码方式打开文件

来源:百度知道 编辑:UC知道 时间:2024/06/23 22:14:40
C#怎么用代码方式打开文件
具体代码是什么?
问题补充:EXE文件 例如: D:\Program Files\san.exe

System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = @"D:\aa.exe";
p.Start();

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace NoteBook
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
if (ofd.ShowDialog() == DialogResult.OK)
{
StreamReader sr = new StreamReader(ofd.FileName);
textBox1.Text = sr.ReadToEnd();
sr.Close();
}

}
}