C# 尝试读取或写入受保护的内存。这通常指示其他内存已损坏
public partial class Form2 : Form{
public Form2()
{
InitializeComponent();
}
string F02= Form1.F01;
private void Form2_Load(object sender, EventArgs e)
{
int m = FindTextForPDF("D:\\FIM\\777_BEJ_FIM_D633W103-BEJ_TD\\PDF\\"+ F02+ "___052.PDF");\\这里变灰
string fileName = "D:\\FIM\\777_BEJ_FIM_D633W103-BEJ_TD\\PDF\\"+ F02+ "___052.PDF";
axAcroPDF1.LoadFile(fileName);
axAcroPDF1.setCurrentPage(m + 1);//里面的数字就是打开时的页面
axAcroPDF1.Show();
}
private static int FindTextForPDF(string pdfFile)
{
string strFindText1="23-39 TASK";string strFindText2="983.";
int findText = -1;
string[] lst = new string[] { };
string strTemp = "d:\\a.txt";
using (PDFWrapper pdf = new PDFWrapper(""))
{
pdf.LoadPDF(pdfFile);
pdf.ExportText(strTemp, 1, pdf.PageCount, false, true);\\这里报错。。。。。
using (System.IO.StreamReader reader = new System.IO.StreamReader(strTemp))
{
string strOut = reader.ReadToEnd();
lst = strOut.Split('');
}
}
for (int i = 0; i < lst.Length; i++)
{
if (lst[i].IndexOf(strFindText1) > 0 && lst[i].IndexOf(strFindText2) > 0)
{
findText = i;
break;
}
}
return findText;
}
}
请问各位高手,这怎么解决???谢谢了。。 --------------------编程问答-------------------- 你运行程序的时候 文件开着的吗? --------------------编程问答-------------------- 你是指pdf么??我没有主动打开它。。。要先自己打开它?? --------------------编程问答-------------------- 你把using 去掉试一下...再看一下你传的参数是否正确.. --------------------编程问答--------------------
补充:.NET技术 , C#