【问题标题】:'System.IO.FileInfo' does not contain a definition for 'FileName'“System.IO.FileInfo”不包含“FileName”的定义
【发布时间】:2011-04-11 10:53:23
【问题描述】:
<asp:GridView runat="server" id="GrdVw_Download">
                        <RowStyle cssclass="ItemStyle" />
                        <HeaderStyle cssclass="tableheader" horizontalalign="Left" />
                        <AlternatingRowStyle cssclass="AlternateItemStyle" horizontalalign="Left" />
                        <FooterStyle backcolor="#5D7B9D" font-bold="True" forecolor="White" />
                        <Columns>
                            <asp:BoundField headertext="File name" headerstyle-horizontalalign="Center" itemstyle-horizontalalign="Center"
                                datafield="FileName" />
                            <asp:BoundField headertext="File Size" headerstyle-horizontalalign="Center" itemstyle-horizontalalign="Center"
                                dataformatstring="{0:#,### bytes}" datafield="Length" />
                            <asp:BoundField headertext="Extension" headerstyle-horizontalalign="Center" itemstyle-horizontalalign="Center"
                                datafield="Extension" />
                            <asp:TemplateField headertext="Download Brochure" itemstyle-horizontalalign="Center"
                                headerstyle-horizontalalign="Center">
                                <ItemTemplate>
                                    <a href="?dl=<%# Encryptor.encrypt(((FileInfo)Container.DataItem).FullName) %>" 
                                    title="Download <%# ((FileInfo)Container.DataItem).FileName %>">
                                        <%# ((FileInfo)Container.DataItem).FileName %>
                                    </a>
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                    </asp:GridView>

这是我的 gridview 标记,下面是数据绑定部分

    DirectoryInfo ProviderFolder = new DirectoryInfo(strFolderPath);
    FileInfo[] BrochureList = ProviderFolder.GetFiles();
    if (BrochureList.Length > 0)
    {
        GrdVw_Download.DataSource = BrochureList;
        GrdVw_Download.DataBind();
    }

在这一行的网格视图中&lt;a href="?dl=&lt;%# Encyptor.encrypt(((FileInfo)Container.DataItem).FullName) 我得到了帖子谈到的错误。 Encryptor 在哪里加密 FilePath 和标记生成一个链接来下载文件 编辑抱歉: *解决了。* 这不是文件名,只是名称。再次抱歉

【问题讨论】:

  • 您应该接受真正解决了您的问题的答案,而不是在问题标题中添加“[已解决]”。
  • @Martin 感谢您提供的信息。我会接受一个答案是他在我更新之前发布了解决方案。当我用我犯的错误更新问题时。

标签: asp.net data-binding gridview directory fileinfo


【解决方案1】:

这是因为 'System.IO.FileInfo' 不包含 'FileName' 的定义

您在寻找FullNameName 吗?

【讨论】:

  • 你一定在我更新的时候发布了这个。我更新了我原来的帖子
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-12-19
  • 2018-01-27
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多