![]() |
#2
编号10162014-06-17 21:41
|

static void Main()
{
string[] getArgs = Environment.GetCommandLineArgs();//获取命令行参数,经测试,打开系统文件时的文件路径在第二行
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new FrmNote(getArgs));
}
{
string[] getArgs = Environment.GetCommandLineArgs();//获取命令行参数,经测试,打开系统文件时的文件路径在第二行
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new FrmNote(getArgs));
}

public FrmNote(string[] getSystemFilePath)
{
if (getSystemFilePath.Length > 1)//调试时命令行参数只有1行,只有当打开系统文件时命令行参数才大于1行
{
MessageBox.Show(getSystemFilePath[1]);
FileStream fs = new FileStream(getSystemFilePath[1], FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
MessageBox.Show("a");
StreamReader sr = new StreamReader(fs);
MessageBox.Show("b");
tbContent.Text = sr.ReadToEnd();
MessageBox.Show("c");
sr.Close();
fs.Close();
}
InitializeComponent();
//ff = new FrmFind();
//ff.Show(this);
//ff.Hide();
}
{
if (getSystemFilePath.Length > 1)//调试时命令行参数只有1行,只有当打开系统文件时命令行参数才大于1行
{
MessageBox.Show(getSystemFilePath[1]);
FileStream fs = new FileStream(getSystemFilePath[1], FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
MessageBox.Show("a");
StreamReader sr = new StreamReader(fs);
MessageBox.Show("b");
tbContent.Text = sr.ReadToEnd();
MessageBox.Show("c");
sr.Close();
fs.Close();
}
InitializeComponent();
//ff = new FrmFind();
//ff.Show(this);
//ff.Hide();
}
public System.Windows.Forms.TextBox tbContent;
尝试打开系统文件时出现异常:
只有本站会员才能查看附件,请 登录
只有本站会员才能查看附件,请 登录
只有本站会员才能查看附件,请 登录
只有本站会员才能查看附件,请 登录
发现问题出现在
tbContent.Text = sr.ReadToEnd();
却不知道怎么解决,毫无头绪