未处理DIRECTORYNOTFOUNDEXCEPTION解决方法
未处理DIRECTORYNOTFOUNDEXCEPTION
如图:

有关代码如下:
如图:
有关代码如下:
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;
using System.Collections;
using SHF_BT;
using SHF_DA;
using SHF_UI;
namespace MES64G08_111_UI
{
public partial class uiMES64G08_111_CourseShow : SHF_UI.uiSHF_CourseBase
{
#region 局部变量
private btSHFPage page;
private btSHFPages pages;
private btSHFUserLogin userLogin;
private string path = Directory.GetCurrentDirectory() + "..\\..\\..\\..\\SHFDB\\Text\\";
#endregion
#region 构造函数
public uiMES64G08_111_CourseShow()
{
InitializeComponent();
}
//从test调入时的构造函数
public uiMES64G08_111_CourseShow(Form callForm, btSHFUserLogin callLog, btSHFPage callPage)
: base(callForm, callLog)
{
InitializeComponent();
this.page = callPage;
this.userLogin = callLog;
pages = new btSHFPages();
}
#endregion
#region 窗口载入
private void uiMES64G08_111_CourseShow_Load(object sender, EventArgs e)
{
}
#endregion
#region 在窗口中显示信息
private void showInfo()//在窗口中显示教学信息
{
string path1 = path + page.TextInfo;
this.readFile(path1, this.richTextBox1);
}
#endregion
#region 读取文本文件的内容(文本文件编码方式:UTF-8)
public void readFile(string path, RichTextBox richTextBox)
{
richTextBox1.Clear();
richTextBox1.SelectionAlignment = HorizontalAlignment.Left;
richTextBox1.SelectionIndent = 20;
richTextBox1.SelectionHangingIndent = -20;
richTextBox1.Multiline = true;
StreamReader din = File.OpenText(path);
String str;
ArrayList al = new ArrayList();
while ((str = din.ReadLine()) != null)
{
al.Add(str);
}
foreach (string s in al)
{
richTextBox1.SelectedText += s;
richTextBox1.SelectedText += "\r\n";
}
din.Close();
}