You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

WebBrowser控件无法显示PDF文件的技术问题求助

WebBrowser控件显示PDF仅展示文件名问题

我在使用WebBrowser控件显示PDF文件时遇到问题,控件仅显示PDF文件名,无法加载并展示PDF的实际内容。(截图显示WebBrowser控件区域仅呈现了PDF文件名,未渲染出PDF页面)

相关代码

文件夹选择与PDF文件列表加载代码

FolderBrowserDialog FBD = new FolderBrowserDialog();
if (FBD.ShowDialog() == DialogResult.OK)
{
    //textBox5.Text = new DirectoryInfo(FBD.SelectedPath).Parent.Parent.Name;
                
    string[] files = Directory.GetFiles(FBD.SelectedPath, "*.pdf");
    // string[] dirs = Directory.GetDirectories(FBD.SelectedPath);
    foreach (string file in files)
    {
        listBox1.Items.Add(new FileInfo(file).Name);
    }
}

列表项选中触发WebBrowser导航代码

private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
    string filedirectory = listBox1.SelectedItem.ToString();
    // if (listBox1.SelectedItem != null && listBox1.SelectedItem is string)
    {
        webBrowser1.Navigate(filedirectory);
                            //   if (this.listBox1.SelectedIndex >= 0)
    }
}

内容的提问来源于stack exchange,提问作者Delitur Per

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.21 22:09:15