private void button2_Click(object sender, EventArgs e)
{
if (pdfpath.Equals(""))
{
MessageBox.Show("请先选择要查看的文件", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
else
{
if (File.Exists(pdfpath))
{
axAcroPDF1.LoadFile(pdfpath);
}
else
{
MessageBox.Show("文件不存在", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
axAcroPDF1.LoadFile(path+"xls\\404.pdf");
}
}
}
注:安装AdbeRdr11000_zh_CN11.0.0.379.1410747856.exe阅读器,并添加引用就可以拖拽控件使用了
本文介绍了一个使用C#编写的简单方法来加载并显示PDF文件。如果用户未选择文件或指定路径的文件不存在,则会弹出提示消息。此外,还提供了一个备选方案,即当目标PDF文件不存在时,加载一个默认的404.pdf文件。
1024

被折叠的 条评论
为什么被折叠?



